look_for
每个菜鸟都有雄鹰的梦想 share your knowledge for the World!

导航

 

 

count()

返回给定值在元组中出现的次数

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

  例:

t = ('a','b','ab','b')
print(t.count('b'))

#输出结果:
2

  

index()

返回给定值在元组中第一次出现的序列号,可指定开始和结束的序列号

    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

  例:

t = ('a','b','ab','b')
print(t.index('b'))
print(t.index('b',2,))

#输出结果:
1
3

  

 

posted on 2017-10-27 17:05  look_for  阅读(123)  评论(0)    收藏  举报