s ="Fen fen is very beautiful and Zou kexin is very fascinating"
s1 ="Fen fen"# 返回第一次发现这个字符串的位置
s.find(s1)
s2 ="xiaofen"# 返回-1表示没有找到
s.find(s2)
-1
注意区别
help(str.find)
Help on method_descriptor:
find(...)
S.find(sub[, start[, end]]) -> int
Return the lowest index in S where substring sub is found,
such that sub is contained within S[start:end]. Optional
arguments start and end are interpreted as in slice notation.
Return -1 on failure.
help(str.index)
Help on method_descriptor:
index(...)
S.index(sub[, start[, end]]) -> int
Return the lowest index in S where substring sub is found,
such that sub is contained within S[start:end]. Optional
arguments start and end are interpreted as in slice notation.
Raises ValueError when the substring is not found.