码迷,mamicode.com
首页 > 其他好文 > 详细

while循环

时间:2016-12-10 13:51:14      阅读:120      评论:0      收藏:0      [点我收藏+]

标签:pre   false   end   python   循环   div   style   als   bsp   

例(1)
count_1 = True
while count_1:
    print(‘1‘)
    print(‘2‘)
    count_1 = False
print(‘3‘)

例(2)
count_1 = True
while count_1:
    print(‘1‘)
    print(‘2‘)
    count_1 = False
print(‘3‘)

例(3)
count_1 = 1
count_2 = True
while count_2:
    print(count_1)
    if count_1 == 100:
        count_2 = False
    count_1 +=1
print(‘end.....‘)


例(4)
count_1 = 1
while count_1:
    print(count_1)
    if count_1 == 100:
        break #跳出当前循环
    count_1 +=1
print(‘end.....‘)

例(5)
while True:
    print(‘123‘)
    continue#结束本次循环跳到下一次循环
    pritn(‘456‘)
print(‘end.....‘)

例(3)
count_1 = 0
while True:
    if count_1 == 6 or count_1 == 3:
        count_1 += 1
        continue
    print(count_1)
    count_1 += 1
    if count_1 == 10:
        break
print(‘end.....‘)

  

 

while循环

标签:pre   false   end   python   循环   div   style   als   bsp   

原文地址:http://www.cnblogs.com/cloniu/p/6155402.html

踩
(0)
赞
(0)
   
举报
评论 一句话评论(0)
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!