strig=“what is your name”
substring="name"
str.
endswith
(suffix[, start[, end]])
str.
find
(sub[, start[, end]])
str.
index
(sub[, start[, end]])
str.
rfind
(sub[, start[, end]])
str.
rindex
(sub[, start[, end]])
str.
startswith
(prefix[, start[, end]])
in操作
>>> my_string="what is your name" >>> substring="name" >>> substring in my_string True >>> my_string.find(substring) 13 >>> my_string.rfind(substring) 13 >>> my_string.index(substring) 13 >>> my_string.endwith(substring) Traceback (most recent call last): File "<stdin>", line 1, in <module> AttributeError: 'str' object has no attribute 'endwith' >>> my_string.endswith(substring) True