获取TypeError:第4行的“ NoneType”对象不可迭代

时间:2018-12-06 16:09:30

标签: python for-loop int iteration

   for i in range(122):     
       if i <= 121:         
           for j in range(6):             
               consumption = consumption + df2.loc[df2['Main Load [kWh]']]     
               pos = pos + 1         
            weekly_consumption=weekly_consumption.append(pos,consumption)         
            consumption = 0    
       else:        
           for j in range(1):             
               consumption = consumption + df2.loc[df2['Main Load [kWh]']]             
               pos = pos + 1         
           weekly_consumption=weekly_consumption.append(pos,consumption)         
           consumption = 0

1 个答案:

答案 0 :(得分:1)

您不能对数字进行迭代,而只能对集合进行迭代。您可以尝试一系列数字,例如

for i in range(122):   

或列表,字符串等,例如

for i in '122':