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
append
#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
clear
#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 []
copy
#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
count
#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
extend
#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
index
#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)
insert
#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
pop
#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
remove
#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
reverse
#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
sort

 












 
posted @ 2017-05-09 14:39  lazyball  阅读(353)  评论(0编辑  收藏  举报