天天看点

python 子字符串在字符串中所有的位置代码

import re
    entity_startindex = [i.start() for i in re.finditer(temp_label[0], sentecen)]
           

其中temp_label[0]是子字符串,sentecen是待查找的字符串,如果多次出现都会查找到首位置的index下标