# 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. wamp下配置多域名和访问路径的方法

    wamp下配置多域名和访问路径的方法 1.到安装目录下,打开配置httpd.confD:\wamp\bin\apache\Apache2.2.21\conf\httpd.conf也可以通过wamp图标 ...

  2. php 字符串长度函数

    php 字符串长度函数 php 字符串长度函数,在php测试字符串长度的函数有二个,一个是strlen,另一个是mb_strlen前一个默认是支持,后一个需要开启一个插件,下面我们来介绍一下二个函数的 ...

  3. (iOS)关于键盘遮挡textfield问题

    记录一下自己经常遇到问题.使用textfield(textview).当输入框位置比较靠下时,弹出的键盘会遮挡输入框,这是就需要动态移动输入框编辑状态时self.view的位置, 自己经常用的方法有两 ...

  4. jenkins 安装 + maven + git部署

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

  5. 20145307陈俊达_安卓逆向分析_Xposed的hook技术研究

    20145307陈俊达_安卓逆向分析_Xposed的hook技术研究 引言 其实这份我早就想写了,xposed这个东西我在安卓SDK 4.4.4的时候就在玩了,root后安装架构,起初是为了实现一些屌 ...

  6. 20145331魏澍琛《网络对抗》Exp8 Web基础

    20145331魏澍琛<网络对抗>Exp8 Web基础 实践内容: 1.简单的web前端页面(HTML.CSS等) 2.简单的web后台数据处理(PHP) 3.Mysql数据库 4.一个简 ...

  7. linux内核分析 第18章读书笔记

    十八章 调试 一.内核调试概述 1.需要面对的 一个确定的bug 一个藏匿bug的内核版本 相关的内核代码的知识和运气 2.艰难的调试工作 重现bug很困难:大部分bug通常都不是行为可靠而且定义明确 ...

  8. Python3基础 list sort 从小(大)到大(小)排序

             Python : 3.7.0          OS : Ubuntu 18.04.1 LTS         IDE : PyCharm 2018.2.4       Conda ...

  9. linux 下 安装nginx

    http://www.cnblogs.com/lovexinyi8/p/5845017.html 测试可用. 参看 https://www.cnblogs.com/liujuncm5/p/671378 ...

  10. C# String.Join 与 StringBuilder 对比,谁更快

    String.Join 文档      StringBuilder 文档 这两天刷 Leedcode 做到一道 String 的题时突然想到这俩对比的问题,于是查了一下资料并简单对比了一下. 首先对于 ...