在写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。
---------------------
作者:冰雪凌萱
来源:CSDN
原文:https://blog.csdn.net/u012910595/article/details/78551129

python提示AttributeError: 'NoneType' object has no attribute 'append'【转发】的更多相关文章

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

    在写python脚本时遇到AttributeError: 'NoneType' object has no attribute 'append' a=[] b=[1,2,3,4] a = a.appe ...

  2. AttributeError: 'NoneType' object has no attribute 'append'

    大多数是这个原因: gongzi = [] for p in [1,2,3]: gongzi = gongzi.append(p) #改为如下即可 gongzi = [] for p in [1,2, ...

  3. AttributeError: 'NoneType' object has no attribute 'extend'

    Python使用中可能遇到的小问题 AttributeError: 'NoneType' object has no attribute 'extend' 或者AttributeError: 'Non ...

  4. 提示AttributeError: 'module' object has no attribute 'HTTPSHandler'解决方法

    今天在新机器上安装sqlmap,运行提示AttributeError: 'module' object has no attribute 'HTTPSHandler' 网上找了找资料,发现一篇文章ht ...

  5. pyspark AttributeError: 'NoneType' object has no attribute 'setCallSite'

    pyspark: AttributeError: 'NoneType' object has no attribute 'setCallSite' 我草,是pyspark的bug.解决方法: prin ...

  6. python3 AttributeError: 'NoneType' object has no attribute 'split'

    from wsgiref.simple_server import make_server def RunServer(environ, start_response): start_response ...

  7. AttributeError: 'NoneType' object has no attribute 'split' 报错处理

    报错场景 social_django 组件对原生 django 的支持较好, 但是因为 在此DRF进行的验证为 JWT 方式 和 django 的验证存在区别, 因此需要进行更改自行支持 JWT 方式 ...

  8. Keras AttributeError 'NoneType' object has no attribute '_inbound_nodes'

    问题说明: 首先呢,报这个错误的代码是这行代码: model = Model(inputs=input, outputs=output) 报错: AttributeError 'NoneType' o ...

  9. 解决opencv:AttributeError: 'NoneType' object has no attribute 'copy'

    情况一: 路径中有中文,更改即可 情况二:可以运行代码,在运行结束时显示 AttributeError: 'NoneType' object has no attribute 'copy' 因为如果是 ...

随机推荐

  1. javascript正则表达式分组捕获理解

    我们先来看一段js代码: var rquickExpr = /^(?:(<[\w\W]+>)[^>]*|#([\w-]*))$/; console.log(rquickExpr.ex ...

  2. python 二叉树实现带括号的四则运算

    #!/usr/bin/python #* encoding=utf-8 s = "20-5*(0+1)*5^(6-2^2)" c = 0 top = [0,s[c],0] op = ...

  3. 如何在ubuntu中安装php

    如何在ubuntu中安装php 情衅 | 浏览 692 次 发布于2016-05-07 12:36   最佳答案   关于Ubuntu下的LAMP配置步骤: 首先要安装LAMP 就是Apache,PH ...

  4. C# Excel导入数据

    表 表的创建脚本 CREATE TABLE [dbo].[TB_PROJECTS_New1]( , ) NOT NULL, ) NULL, ) NULL, , ) NULL, , ) NULL, , ...

  5. BUG在线上环境中出现的原因总结

    1.线上环境数据的复杂度以及数据量是测试环境不能比拟的. 2.业务操作的不可控性,用户错误的使用习惯. 3.实际场景的复杂性. 上线之后,测试人员需要做好以下二件事:   第一,灰度测试 项目上线之后 ...

  6. MySQL 5.7自定义安装图文详解

    本文教程为大家分享了mysql5.7安装配置方法,供大家参考,具体内容如下 mysql-installer-community-5.7.9.1各版本相关说明: mysql-installer-web- ...

  7. linux下安装zabbix

    1.安装源:sudo rpm -ivh http://repo.zabbix.com/zabbix/3.2/rhel/6/i386/zabbix-release-3.2-1.el6.noarch.rp ...

  8. css3-study-new

    不错的:http://c7sky.com/works/css3slides/#28

  9. 杭电oj 4004---The Frog Games java解法

    import java.util.Arrays; import java.util.Scanner; //杭电oj 4004 //解题思路:利用二分法查找,即先选取跳跃距离的区间,从最大到最小, // ...

  10. iview组件select无法手动设置值

    听小伙伴说iview的作者已经修复这个bug了,因为我们的组件库是copyiview后修改的,所以没有更新代码 这里提供一个方法 <i-select :ref="'signSlectR ...