zoukankan      html  css  js  c++  java
  • python & list对象

    def append(self, p_object): # real signature unknown; restored from __doc__
    """ L.append(object) -> None -- append object to end """
    pass

    append函数将字符串插入到列表自身的末尾

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

    clear函数将清除list所有元素

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

    copy函数将自身拷贝并返回

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

    count函数统计list的元素个数

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

    extend函数将可迭代对象的所有元素插入到自身。

    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方法从字符串中查找与参数2匹配的字符串的第一个位置返回

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

    insert函数将参数3的字符串插入到由参数2指定的位置

    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函数将列表的最后一个pop,列表的长度-1

    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函数将参数2指定的值得元素删除。

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

    reverse函数将列表的元素反向排序

    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函数将列表的数据进行排序,但是只能对同一个数据类型的列表进行排序,如果数字,字母,符号一起排序就会报错。
  • 相关阅读:
    python3 sorted()函数解析
    MySql 关键字
    python的 a,b=b,a+b 和 a=b b=a+b 的区别
    python3 all() 函数用于检查实参
    Python3 urllib模块
    Python3 shutil模块
    Python3 sys模块
    Python 异常处理和断言
    Python3 os模块
    Pytho3 file open方法
  • 原文地址:https://www.cnblogs.com/zxcv-/p/6799967.html
Copyright © 2011-2022 走看看