find() 方法检测字符串中是否包含子字符串 str
str.find(str, beg=0, end=len(string))
str – 指定检索的字符串
beg – 开始索引,默认为0。
end – 结束索引,默认为字符串的长度。
实例:
info = ‘abca’
print info.find(‘a’) # 从下标0开始,查找在字符串里第一个出现的子串,返回结果:0
0
print info.find(‘a’,1) # 从下标1开始,查找在字符串里第一个出现的子串:返回结果3
3
print info.find(‘3’) # 查找不到返回-1
-1