python的循环

一 for循环

(1)

for i in range(10):
print("loop",i)

(2)
for i in range(0,10,2):
print("loop",i)

二 while 循环
(1)
  count = 0
  while (count < 9):
    print 'The count is:', count
    count = count + 1
print "Good bye!"


(2)
count = 10
while count >= 5:
print (count, " 大于或等于 5")
count = count - 1
else:
print (count, " 小于5,退出")



Python 不支持 do〜while 语法、可以使用 while(无限循环)和 break 组合起来实现 do ~ while 语法


原文地址:https://www.cnblogs.com/Samuel-Leung/p/10767845.html