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. NSIS 变量

    $PROGRAMFILES 程序文件目录(通常为 C:\Program Files 但是运行时会检测). $COMMONFILES 公用文件目录.这是应用程序共享组件的目录(通常为 C:\Progra ...

  2. vue实践---vue配合express实现请求数据mock

    mock数据是前端比较常见的技术,这里介绍下vue配合express 实现请求数据mock. 第一步: 安装 express :  npm install express -D 第二步: 简历需要mo ...

  3. EasyAR SDK在unity中的简单配置及构建一个简单场景。

    首先打开EasyAR的官方网站http://www.easyar.cn/index.html,注册登陆之后,打开首页的开发页面. 下载sdk和Unity Samples. 创建一个unity3d工程N ...

  4. 中国程序员如何去 Facebook 工作?

    1.在Facebook,可以选择哪里工作? Facebook 在内地确实没有 Office ,但可以在https://www.facebook.com/careers/?ref=pf#location ...

  5. 序列DP(输出有要求)

    DP Time Limit:10000MS     Memory Limit:165888KB     64bit IO Format:%lld & %llu Submit Status De ...

  6. openssl将私钥和crt证书合成pfx证书

    pfx是什么文件:公钥加密技术12号标准(Public Key Cryptography Standards #12,PKCS#12)为存储和传输用户或服务器私钥.公钥和证书指定了一个可移植的格式.它 ...

  7. 在安装mysql数据库的过程中,显示msvcp100.dll丢失?则么办?

    方案一:重装操作系统为windows10专业版 方案二:问题: 解答: 报错原因是VC运行库不全或者没有安装导致,百度搜索VC集合下载安装, 链接:https://pan.baidu.com/s/1U ...

  8. 九度OJ 1261:寻找峰值点 (基础题)

    时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:500 解决:37 题目描述: 给定一个整数序列,该整数序列存在着这几种可能:先递增后递减.先递减后递增.全递减.全递增. 请找出那个最大值的 ...

  9. The Princess and the Pea,摘自iOS应用Snow White and more stories

    Once upon a time there was a prince who wanted to marry a real princess.从前,有个王子想和真正的公主结婚. He looked ...

  10. Linux安装python3.7.2详细操作步骤

    1.下载Python依赖环境 yum install gcc patch libffi-devel python-devel zlib-devel bzip2-devel openssl-devel ...