python_list
来源:互联网 发布:黑客帝国矩阵革命 bt 编辑:程序博客网 时间:2024/05/29 07:44
list 和tuple的常用函数
list =============
可迭代对象都有:index ,len,切片这些属性
def append(self, p_object)L.append(object) -- append object to end向列表尾部追加一个对象
def count(self, value)L.count(value) -> integer -- return number of occurrences of value返回一个value 出现的次数
def extend(self, iterable)L.extend(iterable) -- extend list by appending elements from the iterable从可迭代对象中增加列表的元素
def index(self, value, start=None, stop=None)L.index(value, [start, [stop]]) -> integer -- return first index of value. Raises ValueError if the value is not present.返回列表中value 出现位置的索引,如果不存在,则报错
def insert(self, index, p_object)L.insert(index, object) -- insert object before index 在列表指定索引之前插入对象
def pop(self, index=None)L.pop([index]) -> item -- remove and return item at index (default last). Raises IndexError if list is empty or index is out of range.移除列表结尾的一个对象,并将该对象返回list = ["tomy","jim","jobs"]print (list)A = list.pop()print Aprint (list)result > ['tomy', 'jim', 'jobs'] jobs ['tomy', 'jim']
def remove(self, value)L.remove(value) -- remove first occurrence of value.移除列表中指定的元素,如果不存在,则报错
def reverse(self)L.reverse() -- reverse *IN PLACE* 翻转列表
tuple ============
def count(self, value)T.count(value) -> integer -- return number of occurrences of value 返回元组中value 的出现次数
def index(self, value, start=None, stop=None)T.index(value, [start, [stop]]) -> integer -- return first index of value. Raises ValueError if the value is not present.返回指定value 在元组中所在的位置
阅读全文
0 0
- Python_list
- Python_List
- python_list
- python_list 之 基本操作
- Python_list和tuple
- Python_List对象内置方法详解
- 如何解决PL/SQL连接Oracle时数据库下拉框为空?
- Java—网络编程实现UDP聊天室(局域网)
- 底部按钮 字体变颜色+焦点事件
- Linux安装vmware workstation
- PAT甲级 1002. A+B for Polynomials (25) c++链表程序
- python_list
- 自定义view之环形进度条加数字
- 将图片设置为网页的背景
- 不戴金箍如何救你,带了金箍如何愛你
- 织梦cms内核vip解析包
- java设计模式 ——观察者模式
- OKHttp + RxJava请求数据
- Fragment的切换方法
- Git的基本使用