In [85]: info = 'my name is insane'
In [86]: info.index('insane')
Out[86]: 11
In [87]: info.find ('insane')
Out[87]: 11
find与index的区别
find如果获取不到,返回-1
index如果获取不到,直接报错
In [88]: info = 'my name is insane'
In [89]: info.find ( 'xiaoming' )
Out [89]: -1
In [90]: info.index( 'xiaoming')
---------------
ValueError
Traceback (most recent call last)
<ipython-input-90-ac642654eb73> in module>
----> 1 info.index( 'xiaoming' )
ValueError: substring not found