AttributeError: NoneType object has no attribute‘’

    科技2022-07-16  129

    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。 对应于这类错误,以后要更加小心检查大小写。

     

    承接Matlab、Python和C++的编程,机器学习、计算机视觉的理论实现及辅导,本科和硕士的均可,咸鱼交易,专业回答请走知乎,详谈请联系QQ号757160542,非诚勿扰。

     

     

    Processed: 0.009, SQL: 8