>>> ma = re.match(r'<([\w]+>)\1','<book>booK>')
>>> ma.groups()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'NoneType' object has no attribute 'groups'
ma = re.match(r'<([\w]+>)\1','<book>book>') print ma.groups() print ma.group()
\1 --> ([\w]+>) --> book>
你是K大写啊, 当然不匹配,所以是NoneType啊
ma = re.match(r'<([\w]+>)\1','<book>booK>',re.I)
the second 'booK' has a capital letter 'K', change 'K' to 'k'