python(1)-简单数据类型
来源:互联网 发布:遗传算法 排课系统 编辑:程序博客网 时间:2024/06/05 10:36
Python的变量与数据类型
“一切数据是对象,一切命名是引用“
Python的数据类型包括 空类型、布尔型、数值类型(整形、长整型、浮点型、复数)、字符串类型(str、unicode)
#_*_coding:utf-8_*_import sysdef main(): sys.stdout.write("这是我的第一个Python程序\n") #字符串类型的定义 str1='i am "student"\n' str2='i am "student" \r' str3=""" hello,world 我爱你 <a href="http://www.baidu.com.cn"></a> """ print u"我是张阳" unicode = u"我" str ="我" print str1,str2,str3 #utf-8编码时,非Unicode字符中一个汉字的长度是3 print len(unicode),len(str) print("下面是对于Python动态数据类型的验证") i=1 #id()获取的是存放数据的内存地址 print i,type(i),id(i) i=100000000000000 print i,type(i),id(i) i=1.11 print i,type(i),id(i) print ("上面是对于Python动态数据类型的验证")def testlist(): #全局变量的定义:不加global关键字的话无法在外部获取到函数内部的关键字 global list list=[] list.append("test1") list.append("test2") print (list)testlist()testlist()if __name__=="__main__": main()
输出结果如下
C:\Python27\python.exe E:/untitled1/mypython1.py['test1', 'test2']['test1', 'test2']这是我的第一个Python程序我是张阳i am "student"i am "student" hello,world 我爱你 <a href="http://www.baidu.com.cn"></a> 1 3下面是对于Python动态数据类型的验证1 <type 'int'> 41247784100000000000000 <type 'long'> 411486241.11 <type 'float'> 41308568上面是对于Python动态数据类型的验证Process finished with exit code 0
0 0
- python(1)-简单数据类型
- Python学习笔记(1)-变量和简单的数据类型
- Python快速入门(1)-变量和简单数据类型
- 变量和简单数据类型(python)
- python简单的数据类型
- Python 变量和简单数据类型
- Python基本数据类型简单介绍
- Python 8种基本数据类型简单实例
- Python -- 1. 变量和简单数据类型
- 第一节.Python变量与简单数据类型
- ActionScript3-1简单数据类型
- Python学习(1):基本数据类型
- Python初接触--数据类型(1)
- 使用Python的数据类型(1)
- python学习(1)基础及数据类型
- Python数据类型 -- 列表1
- Python基础1--数据类型
- Python--day5 数据类型1
- 关于gradle版本问题导致的一系列奇葩问题探讨!
- 浅析python中的变量
- Java Socket 编程 Socket与ServerSocket
- CodeForces 546B
- 《C++》05 C++ 修饰符类型
- python(1)-简单数据类型
- (二)BeautifulSoup的基本了解使用
- Android IPC 之 AIDL(一)
- 阿里云美国服务器上架设VPN/代理不能访问facebook TW
- 字典转模型之KVC和MJExtension底层实现
- iOS中几种数据持久化方案-转自简书
- HDOJ-----1060简单数学题
- 《C++》06 C++ 存储类
- HDU 5651