Python“TypeError: 'NoneType' object is not iterable"原因
Python报 TypeError: 'NoneType' object is not iterable
原因:
None是不可迭代的。
list1 = ["a",'b'] list2 = list1.reverse() # list1.reverse() 不应赋值给另一个变量,此时list2的值为None for i in list2: # 因为list2的值为None,无法迭代,所以报错 print(i)