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' ...
随机推荐
- Java 动态打印菱形代码之for循环的使用
1.自定义空心菱形 void PrintRhombus() { int i, j; int s = 4; for (i = 1; i < 2 * (s + 1); i++) { if (i &l ...
- Spring restful
1. RESTful 不是一项技术,也不是一个标准,而是一种风格,跟servlet不在一个层面上,根本无法比较.一个基于servlet的application也是可以是符合RESTful风格的,换言之 ...
- h5页面在ios机上禁止长按复制
(注意,增加之后需要对input的另外设置,不然输入框无法输入)场景:H5出现一个按钮需要长按几秒展示动画的,如:skcs.net-tactic.com/wap/peace/index,这时就需要用到 ...
- .NET Core 微服务
github 上的资源: EshopOnContainers AiurSoft : 微服务框架 Server酱:是一款「程序员」和「服务器」之间的通信软件. http://sc.ftqq.com/3. ...
- iOS进阶之正则表达式
最近一直在弄正则表达式,于是在这里整理一下,便于日后查阅. 1.常用符号 ^:字符串的开始 $:字符串的结束 *:表示零个或若干个 ?:表示零个或一个 +:表示一个或若干个 | :表示 或 操作 . ...
- 确定有穷自动机(DFA)的化简(最小化)
参考博客地址:https://blog.csdn.net/qq_33605778/article/details/80105658
- P5245 【模板】多项式快速幂
思路 调了半天发现ln忘了清空数组了... 就是这个式子 \[ A^k(x) \equiv e^{k{\ln (A(x)) }} \] 代码 #include <cstdio> #incl ...
- java基础--集合框架的认识
一.集合框架 对于不知道存储数量和更复杂的方式存储对象用集合框架. 其中有几个常用的接口和实现类:Collection父接口.List接口,Set接口,Map接口, ArrayList实现类.Link ...
- eclipse 下修改Dynamic Web Modulle 的问题
上图右侧圈中位置 有提示对应jdk版本. 若在eclipse修改Dynamic Web Modulle 为3.0失败,可以去项目工作空间文件中的.seting文件下修改: 上图对应的 <ins ...
- [IoC容器Unity]第二回:Lifetime Managers生命周期
1.引言 Unity的生命周期是注册的类型对象的生命周期,而Unity默认情况下会自动帮我们维护好这些对象的生命周期,我们也可以显示配置对象的生命周期,Unity将按照配置自动管理,非常方便,下面就介 ...