• 内置函数list()列表


    class list(object):
    """
    list() -> new empty list
    list(iterable) -> new list initialized from iterable's items
    """
    def append(self, p_object): # real signature unknown; restored from __doc__
    """ L.append(object) -> None -- append object to end

    描述
    append() 方法用于在列表末尾添加新的对象。

    语法
    append()方法语法:
    list.append(obj)

    参数
    obj -- 添加到列表末尾的对象。

    返回值
    该方法无返回值,但是会修改原来的列表。

    实例
    以下实例展示了 append()函数的使用方法:
    #!/usr/bin/python3

    list1 = ['Google', 'Runoob', 'Taobao']
    list1.append('Baidu')
    print ("更新后的列表 : ", list1)
    以上实例输出结果如下:
    更新后的列表 : ['Google', 'Runoob', 'Taobao', 'Baidu']

    """
    pass

    def clear(self): # real signature unknown; restored from __doc__
    """ L.clear() -> None -- remove all items from L

    描述
    clear() 函数用于清空列表,类似于 del a[:]。

    语法
    clear()方法语法:
    list.clear()

    返回值
    该方法没有返回值。

    实例
    以下实例展示了 clear()函数的使用方法:
    #!/usr/bin/python3

    list1 = ['Google', 'Runoob', 'Taobao', 'Baidu']
    list1.clear()
    print ("列表清空后 : ", list1)
    以上实例输出结果如下:
    列表清空后 : []

    """
    pass

    def copy(self): # real signature unknown; restored from __doc__
    """ L.copy() -> list -- a shallow copy of L

    描述
    copy() 函数用于复制列表,类似于 a[:]。

    语法
    copy()方法语法:
    list.copy()

    返回值
    返回复制后的新列表。

    实例
    以下实例展示了 copy()函数的使用方法:
    #!/usr/bin/python3

    list1 = ['Google', 'Runoob', 'Taobao', 'Baidu']
    list2 = list1.copy()
    print ("list2 列表: ", list2)
    以上实例输出结果如下:
    list2 列表: ['Google', 'Runoob', 'Taobao', 'Baidu']

    """
    return []

    def count(self, value): # real signature unknown; restored from __doc__
    """ L.count(value) -> integer -- return number of occurrences of value

    描述
    count() 方法用于统计某个元素在列表中出现的次数。

    语法
    count()方法语法:
    list.count(obj)

    参数
    obj -- 列表中统计的对象。

    返回值
    返回元素在列表中出现的次数。

    实例
    以下实例展示了 count()函数的使用方法:
    #!/usr/bin/python3

    aList = [123, 'Google', 'Runoob', 'Taobao', 123];

    print ("123 元素个数 : ", aList.count(123))
    print ("Runoob 元素个数 : ", aList.count('Runoob'))
    以上实例输出结果如下:
    123 元素个数 : 2
    Runoob 元素个数 : 1

    """
    return 0

    def extend(self, iterable): # real signature unknown; restored from __doc__
    """ L.extend(iterable) -> None -- extend list by appending elements from the iterable

    描述
    extend() 函数用于在列表末尾一次性追加另一个序列中的多个值(用新列表扩展原来的列表)。

    语法
    extend()方法语法:
    list.extend(seq)

    参数
    seq -- 元素列表。

    返回值
    该方法没有返回值,但会在已存在的列表中添加新的列表内容。

    实例
    以下实例展示了 extend()函数的使用方法:
    #!/usr/bin/python3

    list1 = ['Google', 'Runoob', 'Taobao']
    list2=list(range(5)) # 创建 0-4 的列表
    list1.extend(list2) # 扩展列表
    print ("扩展后的列表:", list1)
    以上实例输出结果如下:
    扩展后的列表: ['Google', 'Runoob', 'Taobao', 0, 1, 2, 3, 4]

    """
    pass

    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.

    描述
    index() 函数用于从列表中找出某个值第一个匹配项的索引位置。

    语法
    index()方法语法:
    list.index(obj)

    参数
    obj -- 查找的对象。

    返回值
    该方法返回查找对象的索引位置,如果没有找到对象则抛出异常。

    实例
    以下实例展示了 index()函数的使用方法:
    #!/usr/bin/python3

    list1 = ['Google', 'Runoob', 'Taobao']
    print ('Runoob 索引值为', list1.index('Runoob'))
    print ('Taobao 索引值为', list1.index('Taobao'))
    以上实例输出结果如下:
    Runoob 索引值为 1
    Taobao 索引值为 2

    """
    return 0

    def insert(self, index, p_object): # real signature unknown; restored from __doc__
    """ L.insert(index, object) -- insert object before index

    描述
    insert() 函数用于将指定对象插入列表的指定位置。

    语法
    insert()方法语法:
    list.insert(index, obj)

    参数
    index -- 对象obj需要插入的索引位置。
    obj -- 要插入列表中的对象。

    返回值
    该方法没有返回值,但会在列表指定位置插入对象。

    实例
    以下实例展示了 insert()函数的使用方法:
    #!/usr/bin/python3

    list1 = ['Google', 'Runoob', 'Taobao']
    list1.insert(1, 'Baidu')
    print ('列表插入元素后为 : ', list1)
    以上实例输出结果如下:
    列表插入元素后为 : ['Google', 'Baidu', 'Runoob', 'Taobao']

    """
    pass

    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.

    描述
    pop() 函数用于移除列表中的一个元素(默认最后一个元素),并且返回该元素的值。

    语法
    pop()方法语法:
    list.pop(obj=list[-1])

    参数
    obj -- 可选参数,要移除列表元素的对象。

    返回值
    该方法返回从列表中移除的元素对象。

    实例
    以下实例展示了 pop()函数的使用方法:
    #!/usr/bin/python3

    list1 = ['Google', 'Runoob', 'Taobao']
    list1.pop()
    print ("列表现在为 : ", list1)
    list1.pop(1)
    print ("列表现在为 : ", list1)
    以上实例输出结果如下:
    列表现在为 : ['Google', 'Runoob']
    列表现在为 : ['Google']

    """
    pass

    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.

    描述
    remove() 函数用于移除列表中某个值的第一个匹配项。

    语法
    remove()方法语法:
    list.remove(obj)

    参数
    obj -- 列表中要移除的对象。

    返回值
    该方法没有返回值但是会移除两种中的某个值的第一个匹配项。

    实例
    以下实例展示了 remove()函数的使用方法:
    #!/usr/bin/python3

    list1 = ['Google', 'Runoob', 'Taobao', 'Baidu']
    list1.remove('Taobao')
    print ("列表现在为 : ", list1)
    list1.remove('Baidu')
    print ("列表现在为 : ", list1)
    以上实例输出结果如下:
    列表现在为 : ['Google', 'Runoob', 'Baidu']
    列表现在为 : ['Google', 'Runoob']
    """
    pass

    def reverse(self): # real signature unknown; restored from __doc__
    """ L.reverse() -- reverse *IN PLACE*

    描述
    reverse() 函数用于反向列表中元素。

    语法
    reverse()方法语法:
    list.reverse()

    返回值
    该方法没有返回值,但是会对列表的元素进行反向排序。

    实例
    以下实例展示了 reverse()函数的使用方法:
    #!/usr/bin/python3

    list1 = ['Google', 'Runoob', 'Taobao', 'Baidu']
    list1.reverse()
    print ("列表反转后: ", list1)
    以上实例输出结果如下:
    列表反转后: ['Baidu', 'Taobao', 'Runoob', 'Google']
    """
    pass

    def sort(self, key=None, reverse=False): # real signature unknown; restored from __doc__
    """ L.sort(key=None, reverse=False) -> None -- stable sort *IN PLACE*

    描述
    sort() 函数用于对原列表进行排序,如果指定参数,则使用比较函数指定的比较函数。

    语法
    sort()方法语法:
    list.sort([func])

    参数
    func -- 可选参数, 如果指定了该参数会使用该参数的方法进行排序。

    返回值
    该方法没有返回值,但是会对列表的对象进行排序。

    实例
    以下实例展示了 sort()函数的使用方法:
    #!/usr/bin/python3

    list1 = ['Google', 'Runoob', 'Taobao', 'Baidu']
    list1.sort()
    print ("列表排序后 : ", list1)
    以上实例输出结果如下:
    列表排序后 : ['Baidu', 'Google', 'Runoob', 'Taobao']

    """
    pass

    def __add__(self, *args, **kwargs): # real signature unknown
    """ Return self+value. """
    pass

    def __contains__(self, *args, **kwargs): # real signature unknown
    """ Return key in self. """
    pass

    def __delitem__(self, *args, **kwargs): # real signature unknown
    """ Delete self[key]. """
    pass

    def __eq__(self, *args, **kwargs): # real signature unknown
    """ Return self==value. """
    pass

    def __getattribute__(self, *args, **kwargs): # real signature unknown
    """ Return getattr(self, name). """
    pass

    def __getitem__(self, y): # real signature unknown; restored from __doc__
    """ x.__getitem__(y) <==> x[y] """
    pass

    def __ge__(self, *args, **kwargs): # real signature unknown
    """ Return self>=value. """
    pass

    def __gt__(self, *args, **kwargs): # real signature unknown
    """ Return self>value. """
    pass

    def __iadd__(self, *args, **kwargs): # real signature unknown
    """ Implement self+=value. """
    pass

    def __imul__(self, *args, **kwargs): # real signature unknown
    """ Implement self*=value. """
    pass

    def __init__(self, seq=()): # known special case of list.__init__
    """
    list() -> new empty list
    list(iterable) -> new list initialized from iterable's items
    # (copied from class doc)
    """
    pass

    def __iter__(self, *args, **kwargs): # real signature unknown
    """ Implement iter(self). """
    pass

    def __len__(self, *args, **kwargs): # real signature unknown
    """ Return len(self). """
    pass

    def __le__(self, *args, **kwargs): # real signature unknown
    """ Return self<=value. """
    pass

    def __lt__(self, *args, **kwargs): # real signature unknown
    """ Return self<value. """
    pass

    def __mul__(self, *args, **kwargs): # real signature unknown
    """ Return self*value.n """
    pass

    @staticmethod # known case of __new__
    def __new__(*args, **kwargs): # real signature unknown
    """ Create and return a new object. See help(type) for accurate signature. """
    pass

    def __ne__(self, *args, **kwargs): # real signature unknown
    """ Return self!=value. """
    pass

    def __repr__(self, *args, **kwargs): # real signature unknown
    """ Return repr(self). """
    pass

    def __reversed__(self): # real signature unknown; restored from __doc__
    """ L.__reversed__() -- return a reverse iterator over the list """
    pass

    def __rmul__(self, *args, **kwargs): # real signature unknown
    """ Return self*value. """
    pass

    def __setitem__(self, *args, **kwargs): # real signature unknown
    """ Set self[key] to value. """
    pass

    def __sizeof__(self): # real signature unknown; restored from __doc__
    """ L.__sizeof__() -- size of L in memory, in bytes """
    pass

    __hash__ = None
  • 相关阅读:
    第二次团队作业
    第一次团队作业
    软件工程结对编程第二次作业
    第四次软件工程作业
    Hadoop综合大作业
    hive基本操作与应用
    熟悉HBase基本操作
    爬虫大作业(爬取广州番禺职业技术学院新闻发布方)
    熟悉常用的HDFS操作
    数据结构化与保存
  • 原文地址:https://www.cnblogs.com/changha0/p/7909597.html
Copyright © 2020-2023  润新知