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 语法


posted @ 2019-04-25 13:12  Samuel-Leung  阅读(210)  评论(0编辑  收藏  举报