string.find(item) -> item:想查询的元素,返回一个整型
string.index(item) 返回一个整型或者报错
find与index的区别
如果find找不到,会返回-1
如果index找不到元素,会导致程序报错
info = 'python is a good code'
result = info.find('a');
print(result)
result = info.find('ok'); //-1
result = info.index('ok'); //ValueError:substring not found
Believe in yourself