【发布时间】:2016-07-06 03:48:58
【问题描述】:
为什么这个正则表达式会打印('c',) 和()?
我以为"([abc])+" === "([abc])([abc])([abc])..."
>>> import re
>>> m = re.match("([abc])+", "abc")
>>> print m.groups()
('c',)
>>> m.groups(0)
('c',)
>>> m = re.match("[abc]+", "abc")
>>> m.groups()
()
>>> m.groups(0)
()
【问题讨论】:
-
m.group()='abc'(是 m.group 而不是 m.groups)
标签: python regex python-2.7