python 正则表达式

import re
print(re.match('ww', 'ww.wwrunoobww.com'))

执行结果
<re.Match object; span=(0, 2), match='ww'>
这个span是其实匹配下标和的起始和结束下标,那不应该是span=(0,1)吗,还是说这个span返回值第一个参数是起始下标,第二个参数持续了几个字符?

re.MatchObject.span() Method in Python - regex - GeeksforGeeks A Computer Science portal for geeks. It contains well written, well thought and well explained computer science and programming articles, quizzes and practice/competitive programming/company interview Questions. https://www.geeksforgeeks.org/re-matchobject-span-method-in-python-regex .

img


也就是说这个span的ending和一般定义类似,是左闭右开的[a,b)这种形式
有帮助望采纳