AttributeError: NoneType object has no attribute‘’

时间:2022-07-26
本文章向大家介绍AttributeError: NoneType object has no attribute‘’,主要内容包括其使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。

交流、咨询,有疑问欢迎添加QQ 2125364717,一起交流、一起发现问题、一起进步啊,哈哈哈哈哈

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

各位看官老爷,如果觉得对您有用麻烦赏个子,创作不易,0.1元就行了。下面是微信乞讨码:

添加描述

添加描述