什么是TypeError: 'NoneType'对象是不可迭代的意思?例子:

for row in data:  # Gives TypeError!
    print(row)

当前回答

表示data的值为None。

其他回答

表示data的值为None。

你用这样的参数调用write_file:

write_file(foo, bar)

但是你没有正确地定义'foo',或者你在你的代码中有一个拼写错误,所以它创建了一个新的空变量并传入它。

我在数据库里对熊猫犯了这个错误。

此错误的解决方案是在集群中安装库 在这里输入图像描述

这意味着data的值为None。

当你得到None Exception时,继续循环,

例子:

   a = None
   if a is None:
       continue
   else:
       print("do something")

这可以是来自DB或excel文件的任何可迭代对象。