>>> a = list()
>>> a
[]
>>> dir(a) #查看list的所有方法
['__add__', '__class__', '__contains__', '__delattr__', '__delitem__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__gt__', '__hash__', '__iadd__', '__imul__', '__init__', '__init_subclass__', '__iter__', '__le__', '__len__', '__lt__', '__mul__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__reversed__', '__rmul__', '__setattr__', '__setitem__', '__sizeof__', '__str__', '__subclasshook__', 'append', 'clear', 'copy', 'count', 'extend', 'index', 'insert', 'pop', 'remove', 'reverse', 'sort']
append() 尾部追加元素
>>> a.append("5")
>>> a
['5']
>>> a.append("6")
>>> a
['5', '6']
insert() 指定位置插入元素
>>> a.insert(0,'55')
>>> a
['55', '5', '6']
extend() 将列表中的所有元素追加到列表的末尾
>>> b = ['s','sd']
>>> a.extend(b)
>>> a
['55', '5', '6', 's', 'sd']
remove()移除指定元素
>>> a.remove("sd")
>>> a
['55', '5', '6', 's']
pop() 弹出元素(不带参弹出末尾元素,带参弹出指定索引元素)
>>> a
['55', '5', '6', 's']
>>> a.pop()
's'
>>> a
['55', '5', '6']
>>> a.pop(0)
'55'
>>> a
['5', '6']
count()查看指定元素出现的次数
>>> a = ['8','6','8','8']
>>> a.count('8')
3
>>> a.count('6')
1
sort()将列表中的元素从小到大排序
>>> a.sort()
>>> a
['6', '8', '8', '8']
reverse() 将列表中的元素从尾到首排序
>>> a.reverse()
>>> a
['8', '8', '8', '6']
copy() 复制列表
>>> d = a.copy()
>>> d
['8', '8', '8', '6']
clear() 清空列表
>>> a.clear()
>>> a
[]