index用于返回指定值在序列的第一個位置
序列.index(值,開始索引,結束索引)
開始索引默認為0,可不傳
結束索引默認為序列長度,可不傳
>>> str = 'abc' >>> str.index('a') 0 >>> str.index('b') 1 >>> str.index('bc') 1 >>> str.index('a',1) Traceback (most recent call last): File "<pyshell#19>", line 1, in <module> str.index('a',1) ValueError: substring not found >>> str.index('b',1) 1
浙公網(wǎng)安備 33010602011771號