小册名称:Python合辑2-字符串常用方法
22、rfind()
类似于find()函数,返回字符串最后一次出现的位置,如果没有匹配项则返回-1。
s = 'Machine Learning'idx = s.rfind('a')print(idx)print(s[idx:])# 10# arning
s = 'Machine Learning'
idx = s.rfind('a')
print(idx)
print(s[idx:])
# 10
# arning