首页 > 移动平台 > 详细

python提示AttributeError: 'NoneType' object has no attribute 'append'

时间:2018-05-28 10:56:07      阅读:387      评论:0      收藏:0      [点我收藏+]
在写python脚本时遇到AttributeError: ‘NoneType‘ object has no attribute ‘append‘
a=[]
b=[1,2,3,4]
a = a.append(b)
执行一次后发现a的类型变为了NoneType。
下次执行时就会出现如题所示的错误。
把a = a.append(b)改为a.append(b)后问题解决。

原因:append会修改a本身,并且返回None。不能把返回值再赋值给a。

python提示AttributeError: 'NoneType' object has no attribute 'append'

原文:https://www.cnblogs.com/omg-hxy/p/9098596.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!