append导致TypeError: 'NoneType' object is not iterable
a=[1,2,3]
a.append(4)
a
Out[4]: [1, 2, 3, 4]
a=a.append(5)
print(a)
None
a =[1,2,3]
print(a.append(4))
None
a
Out[10]: [1, 2, 3, 4]
因为:
描述
append() 方法用于在列表末尾添加新的对象。
语法
append()方法语法:
list.append(obj)
参数
- obj -- 添加到列表末尾的对象。
返回值
该方法无返回值,但是会修改原来的列表。
------------------------
当一个函数没有return语句,函数会返回None,此时如果将函数返回值赋给多个变量,则容易出现上述错误。
append导致TypeError: 'NoneType' object is not iterable的更多相关文章
- python TypeError: 'NoneType' object is not iterable
list(set(map(lambda tp_id : tp_id if not ('#' in tp_id) and len(tp_id.strip().replace('\n', '')) > ...
- python"TypeError: 'NoneType' object is not iterable"错误解析
尊重原创博主,原文链接:https://blog.csdn.net/dataspark/article/details/9953225 [解析] 一般是函数返回值为None,并被赋给了多个变量. 实例 ...
- 'NoneType' object is not iterable
"TypeError: 'NoneType' object is not iterable" 一般是返回值为None同时赋值给了多个变量
- Python问题:'Nonetype' object is not iterable
参考链接:http://blog.csdn.net/dataspark/article/details/9953225 [解析] 这个错误提示一般发生在将None赋给多个值时. [案例] 定义了如下的 ...
- TypeError: 'ExcelData' object is not iterable
今天写了个测试的代码,结果在执行test_register.py文件在调用readexcle.py的时候一直报错TypeError: 'ExcelData' object is not iterabl ...
- TypeError: 'NoneType' object is not subscriptable
运行,显示TypeError: 'NoneType' object is not subscriptable错误信息,原因是变量使用了系统内置的关键字list 重新定义下这个变量就好了
- TypeError: 'TestCase' object is not iterable
这个异常呢其实是因为我对list没有足够熟悉 我一开始很疑惑,明明已经正确返回testcase对象了呀,为啥会报TypeError: 'TestCase' object is not iterable ...
- python报错Nonetype object is not iterable
https://www.cnblogs.com/zhaijiahui/p/8391701.html 参考链接:http://blog.csdn.net/dataspark/article/detail ...
- Python : TypeError: 'int' object is not iterable
用循环依次对list中的每个名字打印出 Hello, xxx! -------------------------------------------------------- L = ['Bart' ...
随机推荐
- 前端JS插件整理
1.JQuery.js JavaScript 库,简化JS. 官网地址:https://jquery.com/ 菜鸟教程:http://www.runoob.com/jquery/jquery-tut ...
- uva 10123 - No Tipping dp 记忆化搜索
这题的题意是 在双脚天平上有N块东西,依次从上面取走一些,最后使得这个天平保持平衡! 解题: 逆着来依次放入,如果可行那就可以,记得得有木板自身的重量. /********************** ...
- Xamarin.Forms + Prism,整理页面导航跳转流程
3个Page,Page1 -> Page2 -> Page3 -> Page2 -> Page1. PageViewModel实现接口:INavigatingAware, IN ...
- drf 单表
^_^ # [{title,price},{}] 构造的数据结构 简单的FBV/CBV def showbooks(request): # FBV if request.method =='GET': ...
- CentOS7 手动部署flannel并启用vxlan
本以为docker准备妥当之后,就可以直接上k8s了,结果yum install kubernetes,报错:Error: docker-ce conflicts with docker-1.9.1 ...
- Git仓库完全迁移,包括所有的分支和标签,当然也包括日志
一.删除原有远程仓库地址 git remote rm origin 添加新的仓库地址 cd existing_repo git remote add origin <URL> git pu ...
- 操作redis
数据库分为: 1)传统的关系型数据库 mysql.oracle.sql server.sqllie.db2 id name passwd cratetime stu 特点: a 数据存在磁盘上 b 使 ...
- centos安装图形界面
1.首先安装X(X Window System),命令为 yum groupinstall "X Window System" 回车 2.由于这个软件组比较大,安装过程会比较 ...
- centos6/7破解root密码的操作
Centos 6 1.开机按“Esc”键 2.按e键进入编辑模式后,选择Kernel /vmlinuz-2.6.92......项 3.进入该编辑模式后,在quiet后面输入simple或者数字1后, ...
- 一款非常好用的 Windows 服务开发框架,开源项目Topshelf
Topshelf是一个开发windows服务的比较好的框架之一,以下演示如何开发Topshelf服务. 1.首先打开你的vs.新建一个TopshelfStudy控制台程序,如下图所示: 这是我用vs2 ...