# while 条件:
# 循环体的代码1
# 循环体的代码2
# 循环体的代码3
# count=0
# while count < 10:
# print(count)
# count+=1 # while True: #死循环
# print('ok') # while 1: #死循环
# print('ok') #break:跳出本层循环
# count=0
# while count < 10:
# if count == 5:
# break
# print(count)
# count+=1 #continue:跳出本次循环
#0 1 2 3 7 8 9 # count=0
# while count < 10:
# if count >=4 and count <=6:
# count += 1
# continue
# print(count)
# count+=1 # OLDBOY_AGE=56
# while 1:
# age=input('猜一猜年龄>>: ')
# age=int(age)
#
# if age > OLDBOY_AGE:
# print('太大了')
# elif age < OLDBOY_AGE:
# print('太小了')
# else:
# print('猜对了')
# break # OLDBOY_AGE=56
# count=1
# while count <= 3:
# age=input('猜一猜年龄>>: ')
# age=int(age)
#
# if age > OLDBOY_AGE:
# print('太大了')
# count+=1
# elif age < OLDBOY_AGE:
# print('太小了')
# count+=1
# else:
# print('猜对了')
# break # OLDBOY_AGE=56
# count=1
# while True:
# if count > 3:
# print('您猜的次数超过限制')
# break
# age=input('猜一猜年龄>>: ')
# age=int(age)
#
# if age > OLDBOY_AGE:
# print('太大了')
# elif age < OLDBOY_AGE:
# print('太小了')
# else:
# print('猜对了')
# break
# count += 1 # while True:
# score = input('>>: ')
# score = int(score)
#
# if score >= 90:
# print('A')
# if score >= 80:
# print('B')
# if score >= 70:
# print('C')
# if score >= 60:
# print('D')
# if score < 60:
# print('E') # OLDBOY_AGE=56
# count=0
# while True:
# if count > 2:
# break
# age=input('猜一猜年龄>>: ')
# age=int(age)
# if age > OLDBOY_AGE:
# print('太大了')
#
# if age < OLDBOY_AGE:
# print('太小了')
#
# if age == OLDBOY_AGE:
# print('猜对了')
# break
# count += 1 补充:
while True:
name=input('please input your name: ')
password=input('please input your password: ') if name == 'egon' and password == '123':
print('login successfull')
while True:
cmd=input('>>: ')
if cmd == 'quit':
break
print('====>',cmd)
break tag=True
while tag:
name=input('please input your name: ')
password=input('please input your password: ') if name == 'egon' and password == '123':
print('login successfull')
while tag:
cmd=input('>>: ')
# if cmd == 'quit':
# tag=False
# continue
# print('====>',cmd) if cmd == 'quit':
tag=False
else:
print('====>',cmd) count=0
while count < 10:
if count == 3:
count+=1
continue
print(count) count+=1
else: #最后执行
print('在最后执行,并且只有在while循环没有被break打断的情况下才执行') 优化:
ount=0
while count < 10:
if count == 3:
pass
else:
print(count)
count+=1

python-day6---while循环的更多相关文章

  1. python基础之循环结构以及列表

    python基础之编译器选择,循环结构,列表 本节内容 python IDE的选择 字符串的格式化输出 数据类型 循环结构 列表 简单购物车的编写 1.python IDE的选择 IDE的全称叫做集成 ...

  2. Python之 for循环\while循环

    list或tuple可以表示一个有序集合.如果我们想依次访问一个list中的每一个元素呢?比如 list: L = ['Adam', 'Lisa', 'Bart'] print L[0] print ...

  3. Python进阶05 循环设计

    作者:Vamei 出处:http://www.cnblogs.com/vamei 欢迎转载,也请保留这段声明.谢谢! 在"循环"一节,我们已经讨论了Python基本的循环语法.这一 ...

  4. 第五篇:python基础之循环结构以及列表

    python基础之循环结构以及列表   python基础之编译器选择,循环结构,列表 本节内容 python IDE的选择 字符串的格式化输出 数据类型 循环结构 列表 简单购物车的编写 1.pyth ...

  5. [Python笔记][第三章Python选择与循环]

    1月28日学习 Python选择与循环 选择结构 多分枝选择结构 if 表达式 1: 语句块 1 elif 表达式 2: 语句块 2 elif 表达式 3: 语句块 3 ... else : 语句块 ...

  6. Python数据结构与循环语句

    # Python数据结构与循环语句:   首先编程是一项技能,类似跑步,期初不必在意细节,能使用起来就行,等学的游刃有余了再回过头来关注细节问题也不迟.  关于买书: 学会python之后,才需要买书 ...

  7. [Python]Python 使用 for 循环的小例子

    [Python]Python 使用 for 循环的小例子: In [7]: for i in range(5): ...: print "xxxx" ...: print &quo ...

  8. 【python】Python3 循环语句

    [python]几种常见的循环 注意:如果涉及到程序中print语句中含有%d,%s,那么要在脚本最开始写语句:#coding=utf-8,才能够正常输出想要的数字或者字符串. Python3 循环语 ...

  9. python入门10 循环语句

    两种循环: 1 for in 2 while #coding:utf-8 #/usr/bin/python """ 2018-11-03 dinghanhua 循环语句 ...

  10. Python中的循环语句

    Python中有while循环和for循环 下面以一个小例子来说明一下用法,用户输入一些数字,输出这些数字中的最大值和最小值 array = [5,4,3,1] for i in array: pri ...

随机推荐

  1. iOS获取本地ip和端口

    #include <arpa/inet.h> #include <ifaddrs.h> #include <net/if.h> #define IOS_CELLUL ...

  2. cursor图标自定义

    cursor: url(./images/favicon.ico), auto; 首先auto必须加上,其次必须使用ico文件,目前来说ico文件没有兼容性问题,ico格式怎么转? 传送门:http: ...

  3. JavaScript计算星期几

    function zeller(dateStr) { var c = parseInt(dateStr.substr(0, 2)); var y = parseInt(dateStr.substr(2 ...

  4. jenkins 安装 + maven + git部署

    1. 安装JDK 2. 安装maven 3. 安装git 4. 安装tomcat tar zxvf apache-tomcat-8.5.14.tar.gz 找到tomcat-->config-- ...

  5. JS(JavaScript)脚本库的积累

    在现在互联网盛行的时代,使得B/S架构飞速发展.曾经在大学的时候我一直都梦想着毕业后要找一个像腾讯这样大企业做C/S方面的开发工作(其实现在腾讯也有很多B/S软件),因为C/S体验度非常高,感觉非常好 ...

  6. Java中线程出现Exception in thread "Thread-0" java.lang.IllegalMonitorStateException异常 解决方法

    代码 package thread; public class TestChongNeng { public static void main(String[] args) { Thread t1 = ...

  7. perl入门知识(3)

    引用       在很多场合下使用引用传值,能在很大程度上提高代码的运行效率.       定义一个引用在变量名前加”\”就可以了,如:       $ra=\$a;       $rb=\@b;   ...

  8. [Redis] - redis实战

    Microsoft Windows [版本 10.0.17134.472] (c) Microsoft Corporation.保留所有权利. C:\Users\SeeClanUkyo>f: F ...

  9. [oracle复习] - Oracle

    https://deadzq.github.io/oracle/Oracle.html 我的oracle笔记1 https://deadzq.github.io/oracle/Oracle2.html ...

  10. 01_Spark基础

    1.1.Spark Ecosystem BlinkDB: 允许用户定义一个错误范围,BlinkDB将在用户给定的错误范围内,尽可能快的提供查询结果 1.2.Spark愿景 1.3.Spark简介 1) ...