for ... in 循环的本质是遍历,for语句模式,for ele in iterable
注意:in 后面是个可迭代对象:比如,字符串、列表、字典、元组、集合、range
sum=0 for i in [1,2,3,4,5,6,7,8,9,10]: i=i+1 sum=sum+i print(sum) # 从2加到11
range区间是左开右闭
for i in range(0,10): #左开右闭,包含左边,不包含右边 print(i) #输出0至9
统计1-100的和
sum=0 for i in range(1,101): #,左开右闭,所以要取到101 sum=sum+i print(sum)