#find(sub,start,end)
#sub为子串,start为开始搜索的索引,end为结束搜索的索引
s="hello sjfk edu xiaoleduong find"*4
sub="edu"
i=0
pos=-len(sub)#记录位置
while i<s.count(sub):
pos=s.find(sub,pos+len(sub))
print(pos,)
i=i+1
find查找子串位置
最新推荐文章于 2023-03-19 15:09:40 发布