这是【Python 百练成钢】系列文章的第 004 篇,计划完成 100 道练习题。
本文环境:python3.8
需求描述:
有两个字符串 s1, s2,找出 s1 中包含的 s2 的起始索引,若有多个,则返回多个索引。
def get_all_index(fullstr: str, substr: str):
"""
返回 substr 在 fullstr 中的起始索引,若匹配多个,则返回多个索引
:param fullstr: 大串
:param substr: 子串
:return: 索引
"""
res_index = [