阅读量:0
for +变量名 in 可迭代对象 temperature_list=[38,36.7,36,35.6] for temperature in temperature_list: if temperature>=38: print(temperature) print("完球了") #对字典进行循环 temperature_dict={"111":39.4,"112":36.6,"113":36.2} for staff_id,temperature in temperature_dict.items(): if temperature>=38: print(staff_id) range range(1,10)#表示从1到10的范围,不包括10 range(1,10,2)#表示1,3,5,7,9 #例子 total=0 for i in range (1,100): total = total + i print(total)