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', '')) > 0
else None, open('tp_list.txt').readlines()).sort()))
为了练习map,想着把一个循环写成一行代码。
结构跑程序时出了一个问题:TypeError: 'NoneType' object is not iterable。
找了半天错误(写成一行代码在这时候真是作死)
发现是sort的问题, list的成员方法sort()将一个list排序(会改变list),但返回None。
None是不可迭代的。所以就报了这么一个错误。
python TypeError: 'NoneType' object is not iterable的更多相关文章
- python"TypeError: 'NoneType' object is not iterable"错误解析
尊重原创博主,原文链接:https://blog.csdn.net/dataspark/article/details/9953225 [解析] 一般是函数返回值为None,并被赋给了多个变量. 实例 ...
- Python : TypeError: 'int' object is not iterable
用循环依次对list中的每个名字打印出 Hello, xxx! -------------------------------------------------------- L = ['Bart' ...
- 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 ...
- Python问题:'Nonetype' object is not iterable
参考链接:http://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
https://www.cnblogs.com/zhaijiahui/p/8391701.html 参考链接:http://blog.csdn.net/dataspark/article/detail ...
- TypeError: 'TestCase' object is not iterable
这个异常呢其实是因为我对list没有足够熟悉 我一开始很疑惑,明明已经正确返回testcase对象了呀,为啥会报TypeError: 'TestCase' object is not iterable ...
- TypeError: 'NoneType' object is not subscriptable
运行,显示TypeError: 'NoneType' object is not subscriptable错误信息,原因是变量使用了系统内置的关键字list 重新定义下这个变量就好了
- TypeError: 'ExcelData' object is not iterable
今天写了个测试的代码,结果在执行test_register.py文件在调用readexcle.py的时候一直报错TypeError: 'ExcelData' object is not iterabl ...
随机推荐
- shell脚本57问
[1]交互方式.非交互方式.Shell脚本是什么? 经常与linux打交道,肯定对shell这个词不陌生.不明白shell意思的,可以自行翻译:外壳.去壳. 这个翻译结果怎么可以与计算机系统联系起来呢 ...
- 地形混合shader
1.四个贴图混合 Shader "Custom/BlendTex_surface" { Properties { _RTexture("Red Channel Textu ...
- 微信小程序事件
微信小程序事件1.什么是事件2.事件类别3.事件冒泡4.事件绑定5.事件对象详解笔记:1.事件是一种用户的行为,是一种通讯方式.2.事件类别: 点击事件:tap 长按事件:longtap ...
- ural 1303 Minimal Coverage【贪心】
链接: http://acm.timus.ru/problem.aspx?space=1&num=1303 http://acm.hust.edu.cn/vjudge/contest/view ...
- iOS使用正则匹配限制输入密码格式
1.代码实现"密码至少为9位,并需包含大写字母.小写字母.数字或特殊字符等三种" 返回0.1.2为格式不正确,返回4为密码格式正确 -(int)checkIsHaveNumAndL ...
- The hidden layers are either convolutional, pooling or fully connected.
https://en.wikipedia.org/wiki/Convolutional_neural_network Convolutional layers apply a convolution ...
- docker 存储定义成direct-lvm 模式
配置direct-lvm模式 1. 停止Docker systemctl stop docker 2. 安装依赖包 device-mapper-persistent-data,lvm2, and ...
- hadoop2.2.0安装需要注意的事情
今天在安装hadoop2.2.0时遇到若干问题,解决这些问题有些心得,记录下来以备不时之需. 问题1.master和slave之间不能相互ssh免密码登陆. 问题表象此处略过,直接说解决办法: 1.查 ...
- Windows存储管理之磁盘类型简介
各种操作系统连接到存储系统之后,并且操作系统识别物理磁盘之后,需要对磁盘进行进一步配置.如果用户连接存储是的Windows Server,存储管理员势必需要了解Windows中的磁盘类型与文件系统.笔 ...
- CentOS iSCSI服务器搭建------LUN篇
先上服务器信息(你懂得) [root@node ~]# cat /etc/redhat-release CentOS release 6.6 (Final) [root@node ~]# uname ...