我收到一条错误消息:
AttributeError: 'NoneType' object has no attribute 'something'
我该如何理解这个消息?
哪些一般情况可能会导致这种情况AttributeError
,以及如何识别问题?
This is a special case of AttributeError
s. It merits separate treatment because there are a lot of ways to get an unexpected None
value from the code, so it's typically a different problem; for other AttributeError
s, the problem might just as easily be the attribute name.
See also What is a None value? and What is a 'NoneType' object? for an understanding of None
and its type, NoneType
.
NoneType 意味着您实际上拥有的不是您认为正在使用的任何类或对象的实例None
。这通常意味着上面的赋值或函数调用失败或返回意外结果。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)