python3模块在字符串上查找子字符串。
findsubstring的Python项目详细描述
查找子字符串
python3模块在字符串上查找子字符串。
基于Karl Knechtel对堆栈溢出的回答: https://stackoverflow.com/questions/4664850/find-all-occurrences-of-a-substring-in-python
安装
使用pip
安装pip3 install -U findsubstring
用法
In [1]: import findsubstring
In [2]: list(
findsubstring.find_all(
str_="spam spam spam spam",
substring="spam"
)
)
Out[2]: [0, 5, 10, 15]