创建
list=['a','b','c',4,5,6]
list1.insert(1,'f')
list1
['a', 'f', 'b', 'c', 4, 5, 6]
修改
list1[0]='HELLO WORD'
list1
['HELLO WORD', 'f', 'b', 'c', 4, 5, 6]
list1.remove('b')
list1
['HELLO WORD', 'f', 'c', 4, 5, 6]
删除
del list1[-1]
list1
['HELLO WORD', 'f', 'c', 4, 5]
list1.pop(1)
'c'
list1
['HELLO WORD']
list[-1]
'hello word'
list[0:2]
['a', 'hello word']
list2=[i for i in range(10)]
list2
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
间隔取数
list2[0:9:3]
[0, 3, 6]
list2[-9:-1:3]
[1, 4, 7]