python正则表达式refindall
导读:python正则表达式refindall?findall是返回所匹配的字符串,返回的是一个列表,并不返回match对象,match对象才有start,span方法importrematchs=re.finditer(r'\w+',"This...
python正则表达式refindall?
findall是返回所匹配的字符串,返回的是一个列表,并不返回match对象,match对象才有start,span方法
importre
matchs=re.finditer(r'\w+',"Thisisatest")
formatchinmatchs:
print(match.start(),match.span())
想找到所有匹配字符串的索引用finditer吧
声明:本文内容由网友自发贡献,本站不承担相应法律责任。对本内容有异议或投诉,请联系2913721942#qq.com核实处理,我们将尽快回复您,谢谢合作!
若转载请注明出处: python正则表达式refindall
本文地址: https://pptw.com/jishu/58207.html
