码迷,mamicode.com
首页 > 其他好文 > 详细

元组tuple常用方法

时间:2017-04-23 14:23:00      阅读:266      评论:0      收藏:0      [点我收藏+]

标签:ror   turn   dex   int   pre   unknown   from   rom   elf   

    元组tuple的功能类似与列表,元组有的功能,列表都有,列表有的,元组不一定有,下面来看看元组具有的功能:

    1.count(self,value)

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

    count(self,value)统计元组中值的个数,实例如下:

    >>> t1 = (11,22,88)
  >>> t1[1]
  22
  >>> t1.count(22)
  1  

    2.index(self,value,start=None,stop=None)

    def index(self, value, start=None, stop=None): # real signature unknown; restored from __doc__
    """
    T.index(value, [start, [stop]]) -> integer -- return first index of value.
    Raises ValueError if the value is not present.
    """
    return 0
 

    index(self,value,start=None,stop=None)查找指定值在元组中的索引,实例如下:

    >>> t1 = (11,22,88)
    >>> t1.index(88)
  2
    其实元组中的方法都是列表中的方法,元组由自己的性质,因为很多方法没有。

元组tuple常用方法

标签:ror   turn   dex   int   pre   unknown   from   rom   elf   

原文地址:http://www.cnblogs.com/gengcx/p/6752341.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!