首页后端开发Pythonpython正则表达式refindall

python正则表达式refindall

时间2023-06-02 12:32:02发布访客分类Python浏览740
导读: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
python语言设有丰富的什么 怎样用链表做贪吃蛇

游客 回复需填写必要信息