您也可以使用
str.index:
>>> 'sdfasdf'.index('cc')Traceback (most recent call last): File "<pyshell#144>", line 1, in <module> 'sdfasdf'.index('cc')ValueError: substring not found>>> 'sdfasdf'.index('df')1
您也可以使用
str.index:
>>> 'sdfasdf'.index('cc')Traceback (most recent call last): File "<pyshell#144>", line 1, in <module> 'sdfasdf'.index('cc')ValueError: substring not found>>> 'sdfasdf'.index('df')1