博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
1.4 python数据类型之list类
阅读量:7036 次
发布时间:2019-06-28

本文共 5359 字,大约阅读时间需要 17 分钟。

类名list

  • 索引: 可以通过索引修改list中元素的值
  • 可迭代: 可以使用for  in  语句循环
1 def append(self, p_object): # real signature unknown; restored from __doc__  2         """ 向列表的末尾添加元素 """  3         """ L.append(object) -> None -- append object to end """  4         pass  5   6     def clear(self): # real signature unknown; restored from __doc__  7         """ 清除列表 """  8         """ L.clear() -> None -- remove all items from L """  9         pass 10  11     def copy(self): # real signature unknown; restored from __doc__ 12         """ 拷贝列表 浅拷贝 """ 13         """ L.copy() -> list -- a shallow copy of L """ 14         return [] 15  16     def count(self, value): # real signature unknown; restored from __doc__ 17         """ 返回子元素出现的次数 """ 18         """ L.count(value) -> integer -- return number of occurrences of value """ 19         return 0 20  21     def extend(self, iterable): # real signature unknown; restored from __doc__ 22         """ x.extend(y) 将y中的元素循环迭代添加到x中""" 23         """ L.extend(iterable) -> None -- extend list by appending elements from the iterable """ 24         pass 25  26     def index(self, value, start=None, stop=None): # real signature unknown; restored from __doc__ 27         """ 返回子元素的索引 start为开始位置 end为结束位置 """ 28         """ 29         L.index(value, [start, [stop]]) -> integer -- return first index of value. 30         Raises ValueError if the value is not present. 31         """ 32         return 0 33  34     def insert(self, index, p_object): # real signature unknown; restored from __doc__ 35         """ 在指定索引处插入元素 """ 36         """ L.insert(index, object) -- insert object before index """ 37         pass 38  39     def pop(self, index=None): # real signature unknown; restored from __doc__ 40         """ 删除列表中的一个元素,index为要删除元素的索引,默认为最后一个元素 """ 41         """ 42         L.pop([index]) -> item -- remove and return item at index (default last). 43         Raises IndexError if list is empty or index is out of range. 44         """ 45         pass 46  47     def remove(self, value): # real signature unknown; restored from __doc__ 48         """ 从列表中删除指定的元素 """ 49         """ 50         L.remove(value) -> None -- remove first occurrence of value. 51         Raises ValueError if the value is not present. 52         """ 53         pass 54  55     def reverse(self): # real signature unknown; restored from __doc__ 56         """ 反转列表 """ 57         """ L.reverse() -- reverse *IN PLACE* """ 58         pass 59  60     def sort(self, key=None, reverse=False): # real signature unknown; restored from __doc__ 61         """ 将列表中的元素排序,reverse=False为升序,reverse=True为降序 key是用来比较的参数 """ 62         """ L.sort(key=None, reverse=False) -> None -- stable sort *IN PLACE* """ 63         pass 64  65     def __add__(self, *args, **kwargs): # real signature unknown 66         """ 列表的加法运算,只能加一个列表类型的对象 """ 67         """ Return self+value. """ 68         pass 69  70     def __contains__(self, *args, **kwargs): # real signature unknown 71         """ 是否包含 """ 72         """ Return key in self. """ 73         pass 74  75     def __delitem__(self, *args, **kwargs): # real signature unknown 76         """ 根据索引删除值 """ 77         """ Delete self[key]. """ 78         pass 79  80     def __eq__(self, *args, **kwargs): # real signature unknown 81         """ 判断左边的列表是或等于右边的列表 """ 82         """ Return self==value. """ 83         pass 84  85     def __getattribute__(self, *args, **kwargs): # real signature unknown 86         """ 内部调用__new__方法或传入参数使用 """ 87         """ Return getattr(self, name). """ 88         pass 89  90     def __getitem__(self, y): # real signature unknown; restored from __doc__ 91         """ 根据索引获取值 """ 92         """ x.__getitem__(y) <==> x[y] """ 93         pass 94  95     def __ge__(self, *args, **kwargs): # real signature unknown 96         """ 判断左边的列表是或大于等于右边的列表 """ 97         """ Return self>=value. """ 98         pass 99 100     def __gt__(self, *args, **kwargs): # real signature unknown101         """ 判断左边的列表是或大于右边的列表 """102         """ Return self>value. """103         pass104 105     def __iadd__(self, *args, **kwargs): # real signature unknown106         """ 将原列表进行加法运算后返回给原列表,可以加一个字符串类型或列表类型的对象 """107         """ Implement self+=value. """108         pass109 110     def __imul__(self, *args, **kwargs): # real signature unknown111         """ 将列表进行乘法运算后返回给原列表 """112         """  """113         """ Implement self*=value. """114         pass115 116     def __init__(self, seq=()): # known special case of list.__init__117         """ 构造方法,创建列表对象时调用 """118         """119         list() -> new empty list120         list(iterable) -> new list initialized from iterable's items121         # (copied from class doc)122         """123         pass124 125     def __iter__(self, *args, **kwargs): # real signature unknown126         """ 返回这个列表的可迭代对象 """127         """ Implement iter(self). """128         pass129 130     def __len__(self, *args, **kwargs): # real signature unknown131         """ 返回列表的长度 """132         """ Return len(self). """133         pass134 135     def __le__(self, *args, **kwargs): # real signature unknown136         """ 判断左边的列表是否小于右边的列表 """137         """ Return self<=value. """138         pass139 140     def __lt__(self, *args, **kwargs): # real signature unknown141         """  """142         """ Return self

 

转载于:https://www.cnblogs.com/rodger/p/10657934.html

你可能感兴趣的文章
开源 java CMS - FreeCMS2.2 敏感词管理
查看>>
域scope 介绍,及查找数据
查看>>
CodeForces 550E Brackets in Implications(构造)
查看>>
uva 10641 (来当雷锋的这回....)
查看>>
go-import下划线的作用
查看>>
Flink – Stream Task执行过程
查看>>
机器学习第1课:引言(Introduction)
查看>>
Echarts柱状图的点击事件
查看>>
shutil模块,ZipFile 和 TarFile 两个模块
查看>>
快速排序,一个爱情故事-java版
查看>>
iOS 输入时键盘处理问题
查看>>
USER Management | Role Categories | Roles | Indirect Responsibilities
查看>>
jquery修改a标签的href链接和文字
查看>>
PHP 使用 GeoLiteCity 库解析 IP 为地理位置
查看>>
win7旗舰版显示不了文件扩展名
查看>>
springMVC--动态验证码实现
查看>>
linux scp 命令
查看>>
Ubuntu Server VS Ubuntu Desktop区别
查看>>
Spring Boot MyBatis升级篇-注解-动态SQL(if test)-方案二:@Provider(8)
查看>>
windows10 Sqlserver卸载 指定账户不存在
查看>>