老师,关于group分组这节课里,那个r变量不应该是一个字符串类型吗,为什么会有group方法,而且我的程序报错了
我的代码
import re
s =‘life is short, i use python’
r= re.search(‘life(\w*)python’, s)
print(r.group(1))
错误提示
Traceback (most recent call last):
File “D:/python_work/April/group.py”, line 5, in
print(r.group(1))
AttributeError: ‘NoneType’ object has no attribute ‘group’