列表(list)
赋值方法:
l = [11,45,67,34,89,23]
l = list()
列表的方法:
1 #!/usr/bin/env python 2 3 class list(object): 4 """ 5 list() -> new empty list 6 list(iterable) -> new list initialized from iterable's items 7 """ 8 def append(self, p_object): # real signature unknown; restored from __doc__ 9 '''在列表末尾添加一个新的对象''' 10 """ L.append(object) -> None -- append object to end """ 11 pass 12 13 def clear(self): # real signature unknown; restored from __doc__ 14 '''清空列表中的所有对象''' 15 """ L.clear() -> None -- remove all items from L """ 16 pass 17 18 def copy(self): # real signature unknown; restored from __doc__ 19 '''拷贝一个新的列表''' 20 """ L.copy() -> list -- a shallow copy of L """ 21 return [] 22 23 def count(self, value): # real signature unknown; restored from __doc__ 24 '''某个元素在列表中出现的次数''' 25 """ L.count(value) -> integer -- return number of occurrences of value """ 26 return 0 27 28 def extend(self, iterable): # real signature unknown; restored from __doc__ 29 '''在列表的末尾追加另外一个列表的多个值''' 30 """ L.extend(iterable) -> None -- extend list by appending elements from the iterable """ 31 pass 32 33 def index(self, value, start=None, stop=None): # real signature unknown; restored from __doc__ 34 '''查找给定值第一次出现的位置''' 35 """ 36 L.index(value, [start, [stop]]) -> integer -- return first index of value. 37 Raises ValueError if the value is not present. 38 """ 39 return 0 40 41 def insert(self, index, p_object): # real signature unknown; restored from __doc__ 42 '''指定位置插入元素''' 43 """ L.insert(index, object) -- insert object before index """ 44 pass 45 46 def pop(self, index=None): # real signature unknown; restored from __doc__ 47 '''移除列表中最后一个元素,并获取这个元素''' 48 """ 49 L.pop([index]) -> item -- remove and return item at index (default last). 50 Raises IndexError if list is empty or index is out of range. 51 """ 52 pass 53 54 def remove(self, value): # real signature unknown; restored from __doc__ 55 '''移除列表中给定值的第一次出现的元素''' 56 """ 57 L.remove(value) -> None -- remove first occurrence of value. 58 Raises ValueError if the value is not present. 59 """ 60 pass 61 62 def reverse(self): # real signature unknown; restored from __doc__ 63 '''反转列表''' 64 """ L.reverse() -- reverse *IN PLACE* """ 65 pass 66 67 def sort(self, key=None, reverse=False): # real signature unknown; restored from __doc__ 68 '''对列表中的元素排序''' 69 """ L.sort(key=None, reverse=False) -> None -- stable sort *IN PLACE* """ 70 pass