尊重原创博主,原文链接:https://blog.csdn.net/dataspark/article/details/9953225 [解析] 一般是函数返回值为None,并被赋给了多个变量. 实例看下: c=0def test(): if c == 1: a = b = 1 return a, b a, b = test() 使用 a, b = test()调用时,就会报错:TypeError: 'NoneType' object is not iterable 在Python判断语句中,当
list(set(map(lambda tp_id : tp_id if not ('#' in tp_id) and len(tp_id.strip().replace('\n', '')) > 0else None, open('tp_list.txt').readlines()).sort())) 为了练习map,想着把一个循环写成一行代码. 结构跑程序时出了一个问题:TypeError: 'NoneType' object is not iterable. 找了半天错误(写成一行代码在这
参考链接: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
https://www.cnblogs.com/zhaijiahui/p/8391701.html 参考链接:http://blog.csdn.net/dataspark/article/details/9953225 Python问题:'Nonetype' object is not iterable
问题描述: 使用excel对接口的数据进行管理,添加接口数据时,可能习惯性选择多行,设置了格式,导致多选了很多空行也被设置了格式,在读取这个sheet的最大行数时,发现有问题,获取到了为None的空行,导致后面的查找方法find,报错"AttributeError: 'NoneType' object has no attribute 'find'" openpyxl分析: openpyxl里sheet.max_row可以获取最大行,但是这个变量有个问题,就是对那些原先有数据,后来又删
这里有两种方法.type 和isinstance import types aaa = 0 print type(aaa) if type(aaa) is types.IntType: print "the type of aaa is int" if isinstance(aaa,int): print "the type of aaa is int" bbb = 'hello' print type(bbb) if type(bbb) is types.Stri