列表List可以添加和删除元素
1 创建列表List
students = [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15] #一维列表
lists = [[1,2],['a','b']] #多维列表
empty = []
2 列表List查询
2.1 print(students[from:to]) 从from到to-1 列表对象
students[0:12] #[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
2.2 list[::step] 从第1个开始,步长为step的列表对象
print(students[::3]) #[0, 3, 6, 9, 12, 15]
2.3 list[i] 下标为i的元素
2.4 list[i] i<0,从列表尾部向前第i个元素
print(students[-3]) #13
3 列表List添加 students.append(14)
列表List添加 lists.append(['Hello',5])
4 列表List删除 students.remove(5)
students.pop(i)
5 列表List修改 students[4]=100
6 列表特殊操作
6.1 列表倒置 students.reverse()
6.2 列表排序 students.sort()
