python提示AttributeError: 'NoneType' object has no attribute 'append'
2017-11-16 14:54
941 查看
在写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。
相关文章推荐
- Python3.4 pandas 在IDLE出现AttributeError: 'NoneType' object has no attribute 'fileno'
- AttributeError: 'NoneType' object has no attribute 'execute' 错误的解决
- Python2.7 安装mock出现AttributeError: 'module' object has no attribute的解决方法
- python “AttributeError: '_csv.reader' object has no attribute'next'” 报错的解决办法
- AttributeError: 'NoneType' object has no attribute 'sc' 解决方法(二)
- AttributeError: 'NoneType' object has no attribute 'copy' 解决办法
- AttributeError: 'NoneType' object has no attribute
- python机器学习实战3.2提示错误AttributeError: type object 'str' has no attribute '_name_'
- 用python爬github上星级排名前列的项目报错AttributeError: 'NoneType' object has no attribute 'decode'
- AttributeError: ‘NoneType’ object has no attribute ‘clone’
- python文件运行报错: 'NoneType' object has no attribute 'TF_DeleteStatus'
- Python 2.7.3 AttributeError: 'module' object has no attribute 'urlopen'
- Python: Attribute Error - 'NoneType' object has no attribute 'something'
- python AttributeError: 'module' object has no attribute 'setdefaultencoding'
- AttributeError: 'NoneType' object has no attribute 'astyp
- python 提示错误AttributeError: type object 'str' has no attribute '_name_'
- python __def__ Exception AttributeError: "'NoneType' object has no attribute
- python django AttributeError: 'QuerySet' object has no attribute '_meta'
- AttributeError: 'NoneType' object has no attribute 'startswith'
- Python报错之:AttributeError: 'NoneType' object has no attribute 'seq'