[英]how to search backwards in python?
I am working with html files which have item 1, item 1a and item 2. is there a way to search backwards and find the item 1a which comes before an item 2? 我正在使用具有项目1,项目1a和项目2的html文件。是否有一种方法可以向后搜索并找到项目2之前的项目1a?
example: 例:
text= """ this is an example item 1a thanks for helping item 2 blah blah item 1a"""
yes... use the 'r' functions: 是的...使用“ r”功能:
text= """ this is an example item 1a thanks for helping item 2 blah blah item 1a"""
text.rfind("1a")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.