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

循环语句--while

时间:2016-08-21 00:38:41      阅读:153      评论:0      收藏:0      [点我收藏+]

标签:

有一种循环叫死循环,一经触发,就运行个天荒地老、海枯石烂

技术分享
1 #coding=utf-8
2 count=0
3 while True:
4     print("你是风儿我是沙,缠缠绵绵到天涯。。。",count)
5     count+=1
View Code

 

其实除了时间,没有什么是永恒的,死loop还是少写为好 

上面的代码循环100次就退出吧

技术分享
1 #coding=utf-8
2 count=0
3 while True:
4     print("你是风儿我是沙,缠缠绵绵到天涯。。。",count)
5     count+=1
6     if count==100:
7         print("去你妈的风和沙。。。")
8         break
View Code

 

上面的代码循环再改一下,count=50至60的时候不打印
技术分享
 1 #coding=utf-8
 2 count=0
 3 while True:
 4     count+=1
 5     if count > 50 and count < 60:
 6         continue
 7     print("你是风儿我是沙,缠缠绵绵到天涯。。。",count)
 8     count+=1
 9     if count==100:
10         print("去你妈的风和沙。。。")
11         break
View Code

 

循环语句--while

标签:

原文地址:http://www.cnblogs.com/Sophia-sugar/p/5791497.html

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