AttributeError: ‘NoneType‘ object has no attribute ‘group‘
生活随笔
收集整理的這篇文章主要介紹了
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())
錯誤處理了 打印結果如下:
總結
以上是生活随笔為你收集整理的AttributeError: ‘NoneType‘ object has no attribute ‘group‘的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 微针一次多少钱啊?
- 下一篇: AttributeError: ‘Non