列表 List
定义
arrList=[2,4,5,6]
访问
arrList[index]访问下标为index的元素
arrList[-index]访问倒数第index个元素
arrList[index1:index2]访问index1与index2之间的元素
常用方法
查看包含的方法
元组 Tuple
Python元组包含了以下内置函数:
1、cmp(tuple1, tuple2):比较两个元组元素。
2、len(tuple):计算元组元素个数。
3、max(tuple):返回元组中元素最大值。
4、min(tuple):返回元组中元素最小值。
5、tuple(seq):将列表转换为元组。
元组tuple与列表List区别
- 元组主要用于查询,它是不可变的List,不能改变元组中的元素值
- List中元素是可变的。
- 速度比List快,代码安全
字典 Dict
定义
a={‘a’:5,’b’:4}
有点类似json