當前位置:成語大全網 - 書法字典 - 求python正則表達式查找函數!

求python正則表達式查找函數!

Findall返回匹配的字符串,並返回壹個列表,但不返回match對象,因此match對象具有start,span方法。

進口re

matchs = re . find ITER(r‘\ w+‘,“這是壹個測試”)

對於匹配中的匹配:

print(match . start()、match.span())

如果要查找所有匹配字符串的索引,請使用finditer。