import re pattern = r'mr_\w' string = 'amr_hearh' match = re.search(pattern,string,re.I) print(match) print("结束:",match.end()) print("开头:",match.start())