Python中index()和seek()的用法(详解)

zhangwei11288 24 0 PDF 2020-12-31 18:12:07

1、index() 一般用处是在序列中检索参数并返回第一次出现的索引,没找到就会报错,比如: >>> t=tuple('Allen') >>> t ('A', 'l', 'l', 'e', 'n') >>> t.index('a') Traceback (most recent call last): File "", line 1, in t.index('a') ValueError: tuple.index(x): x not in tuple >>> t.index('e') 3 >>> t.index('l') 1 但参数可能会出现很

用户评论
请输入评论内容
评分:
暂无评论