python:字符串查找find和index的区别

find()

返回从beg到end发现的第一个子串的位置,没有返回-1

str.find(str,beg=0,end=len(string))

index()

返回从beg到end发现的第一个子串的位置,没有会报错

str.index(str,beg=0,end=len(string))

posted @ 2021-10-29 11:15  Tester-**  阅读(85)  评论(0编辑  收藏  举报