基本数据类型包括:
不可变数据:Number(数字);String(字符串);Tuple(元组)
可变数据:List(列表);Set(集合);Dictionary(字典)
有序序列:String,Tuple,List
无序序列:Set,Dictionary
Number:
int | 整数类型 |
float | 浮点类型 |
bool | 布尔类型 |
complex | 复数类型 |
type() | 变量的对象类型 |
isinstance() | 判断变量所指类型是否是某类型 |
del() | 删除变量 |
String:
索引值以0开始,-1为从末尾的开始位置
Tuple:
tuple=(1,2,3,4)
tuple=(1,) #当只有一个元素时也需要加逗号
List:
list=[1,2,3,4]
dictionary:
dic={key1:value1,key2:value2}
dic={}#空字典
key值唯一
Set:
过滤重复元素
set=set([1,2,3,4])