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
标签:info,index,功能,item,报错,result,find From: https://www.cnblogs.com/qjb2404/p/16972316.html