作者Reinhard (无价)
看板Python
标题[问题] 'NoneType' object is not iterable?
时间Sun Feb 22 12:07:48 2009
我是从 C++ 转到 python 这边来的
一开始有点不习惯的是
function 的 argument 并未指定型别
所以今天碰到了这个问题
传入一个我认为是 list 的东西
但 python 跟我说这是 non-iterable
code:
=======================
def sd_calculation(component_vector):
# calculate the average
for x in component_vector:
sum += x
average = sum / len(component_vector)
print average
=======================
error msg:
'NoneType' object is not iterable
想请教一下各位板友这该如何解决?
还是说 argument 型别是动态型别
我是真的不小心传入了一个 non-iterable 的 object?
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 118.160.39.186
1F:→ Reinhard:原来是动态决定的 我不小心传错东西了 @@ 02/22 12:12