list-列表功能介绍
叨逼叨:列表是可变的,针对列表的改变,变得是列表本身,和字符串区别开来
#1.追加
# name = ['alex','eric','seven','qiqi'] # v = name.append('yangyang') # print(name) # print(v) # #执行结果 # ['alex', 'eric', 'seven', 'qiqi', 'yangyang'] # None
def append(self, p_object): # real signature unknown; restored from __doc__ """ L.append(object) -> None -- append object to end """ pass
#2.清空
# name = ['alex','eric','seven','qiqi'] # name.clear() # print(name) #执行结果 #[]
def clear(self): # real signature unknown; restored from __doc__ """ L.clear() -> None -- remove all items from L """ pass
#3.拷贝复制
# name = ['alex','eric','seven','qiqi'] # v = name.copy() # print(name) # print(v)
def copy(self): # real signature unknown; restored from __doc__ """ L.copy() -> list -- a shallow copy of L """ return []
#4. 统计
# name = ['alex','eric','seven','qiqi','alex'] # num = name.count('alex') # print(num)
def count(self, value): # real signature unknown; restored from __doc__ """ L.count(value) -> integer -- return number of occurrences of value """ return 0
#5.扩展
# name = ['alex','eric','seven','qiqi','alex'] # v = ['cc','dd','ee'] #这种 # name.extend(v) # #name.extend(['aa','bb']) #这种方式 都可以 # print(name)
def extend(self, iterable): # real signature unknown; restored from __doc__ """ L.extend(iterable) -> None -- extend list by appending elements from the iterable """ pass
#6. 根据子序列判断索引位置
#参数1:子序列 必选 #参数2: 区间 # name = ['alex','eric','seven','qiqi','alex'] # v = name.index('alex') # v1 = name.index('alex',3,5) # print(v1) # print(v)
def index(self, value, start=None, stop=None): # real signature unknown; restored from __doc__ """ L.index(value, [start, [stop]]) -> integer -- return first index of value. Raises ValueError if the value is not present. """ return 0
#7.插入
#参数1:插入的索引位置 #参数2:插入的值 # name = ['alex','eric','seven','qiqi','alex'] # name.insert(0,'插入') # print(name)
#参数1:插入的索引位置 #参数2:插入的值 # name = ['alex','eric','seven','qiqi','alex'] # name.insert(0,'插入') # print(name)
#8. 根据索引删除子序列 **并且可以获取元素
# name = ['alex','eric','seven','qiqi','alex' # v= name.pop(3) # print(v) # print(name) # #执行结果 # #qiqi # #['alex', 'eric', 'seven', 'alex']
def pop(self, index=None): # real signature unknown; restored from __doc__ """ L.pop([index]) -> item -- remove and return item at index (default last). Raises IndexError if list is empty or index is out of range. """ pass
#9.删除
# name = ['alex','eric','seven','qiqi','alex'] # name.remove('alex') # print(name)
def remove(self, value): # real signature unknown; restored from __doc__ """ L.remove(value) -> None -- remove first occurrence of value. Raises ValueError if the value is not present. """ pass
#10. 翻转
# name = ['alex','eric','seven','qiqi','alex'] # name.reverse() # print(name)
def reverse(self): # real signature unknown; restored from __doc__ """ L.reverse() -- reverse *IN PLACE* """ pass
#11. 排序 默认从小到大
# num = [11,22,33,44,55,66,23,45,65] # num.sort() # print(num) #反转后 就是从大到小 # num = [11,22,33,44,55,66,23,45,65] # num.sort(reverse=True) # print(num)
def sort(self, key=None, reverse=False): # real signature unknown; restored from __doc__ """ L.sort(key=None, reverse=False) -> None -- stable sort *IN PLACE* """ pass