![b96ef08fb220ce51cc06364068418029.png](https://i-blog.csdnimg.cn/blog_migrate/3046a414673aab15bd0ca0ea36b5f378.jpeg)
用python做数据处理的过程中,往往因为一个很小的点折腾半天,下次再遇上,又来一次,归根结底,基础没打好。
另外,以前数据处理用的R,Python与R对数据的操作差不多,但方式存在诸多差异,容易混淆,接下来会做一次系统的python梳理。
本次梳理来源:
Python3 基本数据类型 | 菜鸟教程www.runoob.com![67c77643474b1a85293bb523ab859717.png](https://i-blog.csdnimg.cn/blog_migrate/74c80aaa5769c311f8e3952705dd34f2.png)
python中有6个标准数据类型:数字、字符串、列表、元祖、集合、字典。
Python3 的六个标准数据类型中:
不可变数据(3 个):Number(数字)、String(字符串)、Tuple(元组)。
可变数据(3 个):List(列表)、Dictionary(字典)、Set(集合)。
不可变的意思在于,在对象有明确的值以后,不能在对对象赋值。
数字Number
python支持int整型、float浮点型、bool布尔型、complex复数。
等号(=)用来给变量赋值。
a = 3
b = 3.0
c = True
d = 1+2j
print(a,b,c,d)
输出结果:
3 3.0 True (1+2j)
也可以同时对多个对象赋值:
a,b,c,d = 3,3.0,True,1+2j
内置的 type() 函数可以用来查询变量所指的对象类型。
print(type(a),type(b),type(c),type(d))
输出为:
<class 'int'> <class 'float'> <class 'bool'> <class 'complex'>
当指定一个值时,Number 对象就会被创建,也可以通过del删除对象应用。
b
3.0
del b
b
Traceback (most recent call last):
File "<input>", line 1, in <module>
NameError: name 'b' is not defined
在使用del语句后,提示对象未被定义。
字符串String
Python中的字符串用单引号
![equation?tex=%27](https://i-blog.csdnimg.cn/blog_migrate/599f083f14816d0537a86cd9fac67ed1.png)