AttributeError: ‘NoneType‘ object has no attribute ‘group‘
这个错误是python 使用match 匹配的时候没有匹配到内容, 仍然使用了 group 这个时候报错了
所以处理方法就是检查下想要匹配的内容是否有写错的地方,
例如下面的代码运行就会报错
str_content = "Python is a good language"
re_content = re.match("python", str_content)
print(re_content)
print(re_content.group())
这里把python 修改为Python 再次运行
str_content = "Python is a good language"
re_content = re.match("Python", str_content)
print(re_content)
print(re_content.group())
错误处理了 打印结果如下:
还没有评论,来说两句吧...