進口re
matchs = re . find ITER(r‘\ w+‘,“這是壹個測試”)
對於匹配中的匹配:
print(match . start()、match.span())
如果要查找所有匹配字符串的索引,請使用finditer。