在写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. tabpanel如何隐藏页签表头以及基本用法总结

    tabpanel是extjs中一种比较常用的布局容器控件,也比较简单. ///1:相关的插件, var tabScrollerMenu = Ext.create("Ext.ux.TabScr ...

  2. es 服务器搭建

    安装jdk,原系统安装的openjava 参考https://www.cnblogs.com/Dylansuns/p/6974272.html注意配置/etc/profile 时,要注意自己安装的是哪 ...

  3. 网络yum源制作

    思路:在网络上准备一个主机,在其中安装一个web服务器软件(比如apache),然后创建一个目录,在这个目录中准备上yum仓库的全部资源,如果用户可以通过网络访问到该主机的这个目录,那么这个目录就成为 ...

  4. Day02 - Ruby比一比:Module模块与Class类别

    前情提要 在第一天里,我很激昂地用Ruby的类别.物件.方法,写了宣言! class TingIsIronman def initialize @message =“I'm going to writ ...

  5. 区间修改区间求和cdq分治

    https://www.luogu.org/problemnew/show/P3372 #include<bits/stdc++.h> #define fi first #define s ...

  6. Apache Flink 分布式运行时环境

    Tasks and Operator Chains(任务及操作链) 在分布式环境下,Flink将操作的子任务链在一起组成一个任务,每一个任务在一个线程中执行.将操作链在一起是一个不错的优化:它减少了线 ...

  7. coderwarrior 查看程序大小 Code Size

    https://mcuoneclipse.com/2012/09/24/code-size-information-with-gcc-for-armkinetis/

  8. About Feature Scaling and Normalization

    在进行数据处理之前,一定要想一想,你的算法是用来做什么,这样才能选择如何对数据进行预处理. 参考网站: http://sebastianraschka.com/Articles/2014_about_ ...

  9. 电话号自动识别之bug解决汇总

    今天测试一个defect: “联系我们”页显示的电话号码,在不同浏览器显示效果不统一,有些浏览器自动识别电话号码并强制添加了样式. 网络搜索发现,其它website 也有类似问题,例如:http:// ...

  10. CentOS7+CDH5.14.0安装全流程记录,图文详解全程实测-2设置SSH免密登录

    因为hadoop集群在安装的时候需要集群中所有机器的权限. 所以我们需要打通所有节点的ssh无密码登陆,思路是生成每台机子的密钥,集中在一个文件中,再分发到每台机子上. 为了确保下面的命令能顺利执行, ...