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的更多相关文章

  1. python"TypeError: 'NoneType' object is not iterable"错误解析

    尊重原创博主,原文链接:https://blog.csdn.net/dataspark/article/details/9953225 [解析] 一般是函数返回值为None,并被赋给了多个变量. 实例 ...

  2. Python : TypeError: 'int' object is not iterable

    用循环依次对list中的每个名字打印出 Hello, xxx! -------------------------------------------------------- L = ['Bart' ...

  3. 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 ...

  4. Python问题:'Nonetype' object is not iterable

    参考链接:http://blog.csdn.net/dataspark/article/details/9953225 [解析] 这个错误提示一般发生在将None赋给多个值时. [案例] 定义了如下的 ...

  5. 'NoneType' object is not iterable

    "TypeError: 'NoneType' object is not iterable" 一般是返回值为None同时赋值给了多个变量

  6. python报错Nonetype object is not iterable

    https://www.cnblogs.com/zhaijiahui/p/8391701.html 参考链接:http://blog.csdn.net/dataspark/article/detail ...

  7. TypeError: 'TestCase' object is not iterable

    这个异常呢其实是因为我对list没有足够熟悉 我一开始很疑惑,明明已经正确返回testcase对象了呀,为啥会报TypeError: 'TestCase' object is not iterable ...

  8. TypeError: 'NoneType' object is not subscriptable

    运行,显示TypeError: 'NoneType' object is not subscriptable错误信息,原因是变量使用了系统内置的关键字list 重新定义下这个变量就好了

  9. TypeError: 'ExcelData' object is not iterable

    今天写了个测试的代码,结果在执行test_register.py文件在调用readexcle.py的时候一直报错TypeError: 'ExcelData' object is not iterabl ...

随机推荐

  1. 嵌入式驱动开发之sensor---"VIP0 PortA", "VIP0 PortB", "VIP1 PortA", "VIP1 PortB",dvo0(vout1) dvo1(vout0)

    (1)vip 简介 (2)vip 电路图 (3)vip 更换采集相机输入 (4)vip 驱动 ---------------------author:pkf --------------------- ...

  2. hdu4063(圆与圆交+线段与圆交+最短路)

    写几何题总是提心吊胆.精度问题真心吓人. 其实思路挺简单的一道题,真是什么算法和几何double搞到一块,心里就虚虚的. 思路:求出所有圆之间的交点,然后用这些交点跑一遍最短路就可以了. Aircra ...

  3. SDOI2012 Round1 day2 拯救小云公主(dis)解题报告

    #include<cstdio> #include<cmath> #include<iostream> using namespace std; typedef l ...

  4. output value . Sigmoid neurons are similar to perceptrons, but modified so that small changes in their weights and bias cause only a small change in their output.

    http://neuralnetworksanddeeplearning.com/chap1.html . Sigmoid neurons are similar to perceptrons, bu ...

  5. Servlet学习笔记【1】--- 背景和基础知识(CGI、Web服务器发展史、Servlet简介、任务、继承结构)

    本文主要讲Servlet的基础知识和背景知识. 1 CGI简介 CGI(Common Gateway Interface 公共网关接口)是WWW技术中最重要的技术之一,有着不可替代的重要地位.CGI是 ...

  6. 矩阵乘法 NOI2012的一道题

    今天,kzj大佬教了我矩阵加速. 让我以这篇随笔表示感谢吧! 这是我刷的一道题:NOI2012 随机数据生成器. 就是普通的矩阵加速,只是要注意的是: 直接用乘法会爆long long,可以参考一下 ...

  7. linux c编程:Posix消息队列

    Posix消息队列可以认为是一个消息链表. 有足够写权限的线程可以往队列中放置消息, 有足够读权限的线程可以从队列中取走消息 在某个进程往一个队列写入消息前, 并不需要另外某个进程在该队列上等待消息的 ...

  8. 代替print输出的PY调试库:PySnooper

      PySnooper¶ Github:https://github.com/lotapp/PySnooper pip install pysnooper 使用:分析整个代码 @pysnooper.s ...

  9. ABAP xml

    [转]Part 1 - Expressiveness of Simple TransformationsSimple Transformations are a SAP proprietary pro ...

  10. 显示HTML的版权符号

    最近有小伙伴问©符号在页面显示很小,于是去查看他的源代码 他在HTML代码里对应输入© 那么在页面里应该会正常显示版权符号,可是为什么会出现这种问题呢? 首先我想到页面在设计的时候,用的字体是宋体,就 ...