尊重原创博主,原文链接:https://blog.csdn.net/dataspark/article/details/9953225

【解析】

一般是函数返回值为None,并被赋给了多个变量。

实例看下:

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

使用 a, b = test()调用时,就会报错:TypeError: 'NoneType' object is not iterable

在Python判断语句中,当if条件不满足并且没有else的时候就会返回None,就算是没有return 也会默认返回None

本例中a,b 都赋予了None值,就出现了上述错误。

所以函数返回值一定要考虑到条件分支的覆盖。

本人是正在读的学生,如有错误还请各路大神慷慨指出,谢谢!

python"TypeError: 'NoneType' object is not iterable"错误解析的更多相关文章

  1. 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', '')) > ...

  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. TypeError: 'NoneType' object is not subscriptable

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

  7. python报错Nonetype object is not iterable

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

  8. TypeError: 'TestCase' object is not iterable

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

  9. TypeError: 'ExcelData' object is not iterable

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

随机推荐

  1. C++ lvalue(左值)和rvalue(右值)

    lvalue(左值)和rvalue(右值) 昨天写代码遇见一个这样的错误:{ "cannot bind non-const lvalue reference of type 'int& ...

  2. react-React深入-一等公民-props-onChange

    title: '[react]深入 - 一等公民 props & onChange' date: 2017-08-23 10:05:07 tags: react reactjs props o ...

  3. C语言库函数strstr、strch比较

    该库函数包含在<string.h>头文件中,函数原型:extern char *strstr(char *str1, const char *str2);使用方法 char *strstr ...

  4. LeetCode 860. 柠檬水找零 (贪心)

    在柠檬水摊上,每一杯柠檬水的售价为 5 美元. 顾客排队购买你的产品,(按账单 bills 支付的顺序)一次购买一杯. 每位顾客只买一杯柠檬水,然后向你付 5 美元.10 美元或 20 美元.你必须给 ...

  5. MySQL安装版安装过程

    步骤1 步骤2 步骤3 步骤4 步骤5 步骤6 步骤7 步骤8 步骤9 步骤10 步骤11 步骤12

  6. RN开发-Linux开发环境搭建(Ubuntu 12.04)

    1.首先安装JDK 2.安装Android开发环境 3.安装node.js 3.1 官网下载 : node-v6.9.1-linux-x64 3.2 添加环境变量 sudo vi /etc/profi ...

  7. 自定义Ribbon客户端策略

    说明   为了实现Ribbon细粒度的划分,让调用不同的微服务时采用不同的客户端负载均衡策略, 通常情况下我们会自定义配置策略.   本文以内容中心(content-center)调用户中心微服务(u ...

  8. ASP.NET MVC 获取表单数据

    public class Person { public string Name{get;set;} public string Phone{get;set;} } view层 @model Mode ...

  9. 10.3.4参数绑定 bind

    Count_if算法,类似find_if,此函数接受一对迭代器,表示一个输入范围,还接受一个谓词,会对输入范围中的每个元素执行.Count_if返回一个计数值,表示谓词有多少次为真.    使用bin ...

  10. PP: Composite visual mapping for time series visualization

    However: The conventional visual mapping maps each data attribute onto a single visual channel Purpo ...