AttributeError: ‘NoneType‘ object has no attribute ‘span‘
生活随笔
收集整理的這篇文章主要介紹了
AttributeError: ‘NoneType‘ object has no attribute ‘span‘
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
span 是返回配置到內(nèi)容的下標,使用span 的時候需要注意,當匹配不到內(nèi)容的時候就會報錯了,
如下的例子就會報錯
str_content = "Python is a good language"
re_content = re.match("python", str_content).span()
print(re_content)
所以修改下要匹配的內(nèi)容即可
如下main的就不會報錯了
str_content = "Python is a good language"
re_content = re.match("Python", str_content).span()
print(re_content)
結(jié)果如下
總結(jié)
以上是生活随笔為你收集整理的AttributeError: ‘NoneType‘ object has no attribute ‘span‘的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 又哭又笑下一句是什么呢?
- 下一篇: 银的多少钱一克啊?