我在下面的代码中得到TypeError: 'int' object is not iterable
,为什么?
def temp_media(c, l):
c_ini = c
l_ini = l
res_vert = 0
res_horiz = 0
dim = dimensoes()
c_max = dim[0] // 2
l_max = dim[1]
for l in l_max:
for c in c_max:
res_vert = res_vert + calcula_temp(c, l)
res_horiz = res_horiz + calcula_temp(c, l)
return (((res_horiz / (c_max - c_ini)) + (res_vert / (l_max - l_ini))) / 2)
我该如何解决这个问题?
答案 0 :(得分:2)
你需要在for循环中使用range
(或python 2中的xrange
):
c_max = dim[0] // 2
l_max = dim[1]
for l in range(l_max):
for c in range(c_max):