在写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. MySQL自增列锁模式 innodb_autoinc_lock_mode不同参数下性能测试

    对于innodb_autoinc_lock_mode 各种参数的值的含义,网上也有各种详解,看完觉得意犹未尽,这里不做阐述,只动手测试,看看性能上,到底有没有理论上所说的差别.对于自增列的锁定,据说是 ...

  2. UE4AI行为树笔记

  3. Kickstart自动化安装平台

    PXE(preboot execute environment,预启动执行环境)是由Intel公司开发的最新技术,工作于Client/Server的网络模式,支持工作站通过网络从远端服务器下载映像,并 ...

  4. Day04 -玩弄Ruby的方法:instance method与class method

    前情提要在第三天时,我们解说了如何在class里用include与extend,去使用module的method. Include is for adding methods to an instan ...

  5. 初识docker

    什么是docker Docker 最初是 dotCloud 公司创始人 Solomon Hykes 在法国期间发起的一个公司内部项目,于 2013 年 3 月以 Apache 2.0 授权协议开源,主 ...

  6. Java 定时任务的几种实现方式

    JAVA实现定时任务的几种方式 @(JAVA)[spring|quartz|定时器]  近期项目开发中需要动态的添加定时任务,比如在某个活动结束时,自动生成获奖名单,导出excel等,此类任务由于活动 ...

  7. mysql 创建备份表

    mysql 中对已有表进行备份用到的语句 CREATE TABLE table_name_1  SELECT * FROM table_name_2; 这个语句是创建表1并且复制表2的结构和数据到表1 ...

  8. max_delay/min_delay和input_delay/output_delay

    今天在使用DC设置随路时钟的时候发现里两个比较容易混淆的设置:max_delay/min_delay和input_delay/output_delay. 1)max_delay/min_delay设置 ...

  9. jQuery index() 方法

    比如同一级有多个li,获得点击的元素的下标,确定第几个. $("li").click(function(){alert($(this).index());});

  10. typename的用法

    template <class T> void foo() { typename T::iterator * iter; } class ContainsAType{ public: cl ...