python报错:AttributeError: 'NoneType' object has no attribute 'append'
程序员文章站
2022-03-26 19:31:52
...
出现这个报错说明你在写程序的时候犯了个基本错误:'append()'函数是没有返回值的。也就是说,你的代码中肯定出现了的这样的语句:
a = []
b = 1
a = a.append(b)
由于append()没有返回值,所以正确的语句应为:
a = []
b = 1
a.append(b)
除了append()之外,还有很多函数是没有返回值的,比如reverse()函数。如果出现了AttributeError: 'NoneType' object has no attribute 'reverse'这样的错误,也做和上面一样的处理就能解决问题。
推荐阅读
-
解决Keras报错AttributeError: 'NoneType' object has no attribute 'inbound_nodes'
-
AttributeError: ‘NoneType‘ object has no attribute ‘origin‘解决办法
-
AttributeError: ‘set‘ object has no attribute ‘append‘解决办法
-
使用torchsummary时报错AttributeError: ‘list‘ object has no attribute ‘size‘
-
Python AttributeError: 'Module' object has no attribute 'STARTF_USESHOWINDOW'
-
Python 爬取网页信息 AttributeError :’NoneType’ object has no attribute ’attrs’
-
python报错:AttributeError: 'module' object has no attribute 'xfeatures2d'
-
python易错点 | AttributeError: 'xxxx' object has no attribute 'xxxx'
-
wsgiref报错AttributeError: 'NoneType' object has no attribute 'split'
-
反向关联报错AttributeError: ‘ForeignKey‘ object has no attribute ‘rel‘从django源码找答案~