下面的代码给我错误 Python
类型错误:“int”对象不可迭代:
代码:
hosts = 2
AppendMat = []
Mat = np.zeros((hosts,hosts))
Mat[1][0] = 5
for i in hosts:
for j in hosts:
if Mat[i][j]>0 and Timer[i][j]>=5:
AppendMat.append(i)
我该如何修复错误 -
TypeError: 'int' object is not iterable?
其次,如果 if 条件为真,我如何附加 i 和 j 的值?在这里,我试图仅附加 i。
最佳答案
试试这个:
for i in xrange(hosts):
关于Python 类型错误 : 'int' object is not iterable,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18595695/