【发布时间】:2020-06-25 23:19:41
【问题描述】:
所以我正在寻找一种方法来查找字符串中子字符串的最后一个索引。这是一些伪代码。
string = "hello 123 this is a test"
substring = "123 this"
>>> string.find_substring_index(substring)
13
"hello 123 this is a test"
# ^
任何内置函数可以做到这一点?还是我必须手动“匹配”字符串并返回最后一次出现?
【问题讨论】:
-
获取子串的索引,然后加上子串的长度。