str1 = "this is really a string example....wow!!!"
str2 = "is"
print(str1.rfind(str2, 10, 0)) # -1
print(str1.find(str2, 10, 0)) # -1
不管是find()还是rfind(),是不是起始索引的位置的数值不能大于结束索引的位置的数值,否则output就是-1?
这样理解正确吗
str1 = "this is really a string example....wow!!!"
str2 = "is"
print(str1.rfind(str2, 10, 0)) # -1
print(str1.find(str2, 10, 0)) # -1
不管是find()还是rfind(),是不是起始索引的位置的数值不能大于结束索引的位置的数值,否则output就是-1?
这样理解正确吗
是的,find()和rfind(),都是起始索引的位置要小于结束索引的位置的
str.rfind(sub[, start[, end]])
返回子字符串 sub 在字符串内被找到的最大(最右)索引,这样 sub 将包含在 s[start:end] 当中。 可选参数 start 与 end 会被解读为切片表示法。 如果未找到则返回 -1。