Python:AttributeError: 问题

来源:互联网 发布:sql语句添加数值 编辑:程序博客网 时间:2024/06/06 06:40

>>> m=re.match(r'WwW\.(.*)\..{3}','www.python.org')
>>> m.group(1)
Traceback (most recent call last):
  File "<pyshell#32>", line 1, in <module>
    m.group(1)
AttributeError: 'NoneType' object has no attribute 'group'

这个问题是因为WwW这里错了,没有获得对应的值

改为以下代码:

>>> m=re.match(r'www\.(.*)\..{3}','www.python.org')

0 0
原创粉丝点击