以下代码:查找content字符串中的所有子串 abc
import re content = 'abc edf abc 1234 abc 45'regex = re.compile(r'abc') ##待查找字符串abctels_obj = regex.finditer(content)tels_list = []for tel in tels_obj: tels_list.append(tel.group()) print(tel) print(tel.span()) ##每个子串的开始和完结地位 print(tel.start()) ##每个子串的开始地位 print(tel.end()) ##每个子串的完结地位print(tels_list)