2013-07-30 22 views
0

我正在處理具有項目1,項目1a和項目2的html文件。是否有方法向後搜索並找到項目2之前的項目1a?如何在Python中向後搜索?

例如:

text= """ this is an example item 1a thanks for helping item 2 blah blah item 1a""" 

回答

4

使用str.rfind()方法來搜索在反向方向上的字符串的發生。 This問題也應該給你如何去一些見識一下

0

是...用「R」功能:

text= """ this is an example item 1a thanks for helping item 2 blah blah item 1a""" 
text.rfind("1a")