1、创建列表
>>list1 = [‘apple‘,‘banana‘,‘parple‘,‘pear‘,‘apple‘]
2、copy操作
>> list2=list1.copy()
>> list2
[‘apple‘, ‘banana‘, ‘parple‘, ‘pear‘, ‘apple‘]
3、append操作
>> list1.append(‘five‘)
>> list1
[‘apple‘, ‘banana‘, ‘parple‘, ‘pear‘, ‘apple‘, ‘five‘]
>> list2
[‘apple‘, ‘banana‘, ‘parple‘, ‘pear‘, ‘apple‘]
>>
4、count操作
>> list1.count(‘apple‘)
2
5、remove操作
>> list1.remove(‘five‘)
>> list1
[‘apple‘, ‘banana‘, ‘parple‘, ‘pear‘, ‘apple‘]
6、reverse操作
>> list1.reverse()
>> list1
[‘apple‘, ‘pear‘, ‘parple‘, ‘banana‘, ‘apple‘]
7、insert操作
>> list1.insert(1,‘shuiguo‘)
>> list1
[‘apple‘, ‘shuiguo‘, ‘pear‘, ‘parple‘, ‘banana‘, ‘apple‘]
8、index操作
>> list1.index(‘pear‘)
2
9、pop操作
>> list1.pop()
‘apple‘
10、sort操作
>> list1.sort()
>> list1
[‘apple‘, ‘banana‘, ‘parple‘, ‘pear‘, ‘shuiguo‘]
11、extend操作
>> inon = [‘aa‘,‘bb‘]
>> list1.extend(inon)
>> list1
[‘apple‘, ‘banana‘, ‘parple‘, ‘pear‘, ‘shuiguo‘, ‘aa‘, ‘bb‘]
12、clear操作
>> list1.clear()
>> list1
[]
原文地址:http://blog.51cto.com/13911856/2158013