break有什么用
sum = 0
x = 1
while True:
sum = sum + x
x = x + 1
if x > 100: #判断x是否>100,如果成立则
break #直接退出循环
print sum
---------------------------------------------------------------------
sum =0
x=1
while x<=100:
sum =sum +x
x= x+1
print sum
上面两段代码运行的结果都一样 那为什们还需要 break?