index()
一般用处是在序列中检索参数并返回第一次出现的索引,没找到就会报错,比如:
>>> t=tuple('Allen')
>>> t
('A', 'l', 'l', 'e', 'n')
>>> t.index('a')
Traceback (most recent call last):
File "<pyshell#2>", line 1, in <module>
t.index('a')
ValueError: tuple.index(x): x not in tuple
>>> t.index('e')
3
>>> t.index('l')
1但参数可能会出现很多次,要如何做呢?
Copyright © 2019- ucpa.cn 版权所有
违法及侵权请联系:TEL:199 18 7713 E-MAIL:2724546146@qq.com
本站由北京市万商天勤律师事务所王兴未律师提供法律服务