AttributeError: NoneType object has no attribute‘’

参考  AttributeError: NoneType object has no attribute‘’ - 云+社区 - 腾讯云

AttributeError: ‘NoneType’ object has no attribute ‘text’

出处

difficult = obj.find('difficult').text

方案

错误提示的是空元素,没有对应的属性。

<object>
    <name>1</name>
    <pose>Unspecified</pose>
    <truncated>0</truncated>
    <Difficult>0</Difficult>

仔细查看可知,原文档中是Difficult而不是difficult。
对应于这类错误,以后要更加小心检查大小写。


版权声明:本文为weixin_36670529原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。