python学习之while语句
2016-11-15 16:30
309 查看
while循环
0
1
2
3
4
5
6
7
8
9
not while,exit...
3.循环跳过中间某段
1
2
3
9
10
not while,exit...
1.简单的while循环 while True: print("1") #这是一个简单的while循环,当等于True时会一直打印1 2.while执行多少次后退出
coun=0 while True: print(coun) coun+=1 if coun == 10: print("not while,exit...") break #循环10次后退出 运行结果:
0
1
2
3
4
5
6
7
8
9
not while,exit...
3.循环跳过中间某段
coun=0 while True: coun+=1 if coun >= 4 and coun <= 8: continue print(coun) if coun == 10: print("not while,exit...") break #打印10个数跳过4和8中间的数 运行结果:
1
2
3
9
10
not while,exit...
相关文章推荐
- python学习之while语句
- Python新手学习基础之条件语句——While循环
- python基础学习(五)while循环语句
- Python学习笔记五:while语句
- python 学习while语句中的break&continue
- python学习之语句:循环语句(for,while)
- 学习笔记☞ python 基础(python3)【三】(转义字符,字符串,while循环,break语句,列表)
- python 学习(五) While 循环语句
- python 学习笔记 while语句(11)
- python学习小结2:if和while控制语句
- Python学习--控制语句:if, while, for, break, continue
- Python学习:两种循环语句for和while
- Python新手学习基础之循环语句——While循环
- python学习2——if语句、elif、if嵌套、while循环、while嵌套
- python 学习 if语句while语句
- Python学习笔记——输入语句和while循环
- python基础学习(3)—while循环语句
- Python新手学习基础之循环语句——While循环
- Python新手学习基础之循环语句——While循环
- 【Python学习笔记】for和while循环语句