python_list

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 A
print (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
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值