1.数据类型
python使用对象模型来存储数据,每一个数据类型都有一个内置的类,每新建一个数据,实际就是一个对象,即所有数据都是对象。
对象的3个特性:
- 身份:即内存地址,可以用id()来获取
- 类型:决定了该对象保存的类型,需要遵循什么规则,可用type()来获取该数据类型
- 值:对象的保存的的真实数据
标准的数据类型:
数字、字符串、列表、元祖、字典
其他类型:
Null、文件、集合、函数、类、模块
1.1数字类型分类
数字类型分为:int()整型、long()长整型、float()浮点型、 complex()复数、bool()布尔值
python2.x区分整型,长整型 ; python3.x的整型和长整型,都是整型,无长整型。
查看数据类型:
1 c:\>python 2 Python 3.5.2 (v3.5.2:4def2a2901a5, Jun 25 2016, 22:18:55) [MSC v.1900 64 bit (AMD64)] on win32 3 Type "help", "copyright", "credits" or "license" for more information. 4 >>> print(type(12)) 5 <class 'int'> 6 >>> print(type(12.12)) 7 <class 'float'> 8 >>> print(type("xixihaha")) 9 <class 'str'>