>>> import re
>>> m = re.search(u'ba[r|z|d]', 'bar')
>>> m
<_sre.SRE_Match object at 0x02027288>
>>> m.group()
'bar'
>>> n = re.search(u'ba[r|z|d]', 'bas')
>>> n.group()
如果没有,它将返回无
Traceback (most recent call last):
File "<pyshell#17>", line 1, in <module>
n.group()
AttributeError: 'NoneType' object has no attribute 'group'