代码点读机 / Python / rfind

rfind Python · 字符串方法

从右边查找子串最后一次出现的位置。

怎么用

字符串.rfind(子串)

小例子

print('hello'.rfind('l'))

运行结果

3

官方文档:https://docs.python.org/zh-cn/3/library/stdtypes.html#string-methods

在代码里遇到不认识的词?打开代码点读机,点一下就懂 → ← Python全部词条