# 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. Linux基础命令---lsattr

    lsattr 显示指定文件或者目录的属性. 此命令的适用范围:RedHat.RHEL.Ubuntu.CentOS.SUSE.openSUSE.Fedora. 1.语法       lsattr [选项 ...

  2. iOS xcode创建静态库封装自己的SDK及使用

    https://www.cnblogs.com/JustForHappy/p/5773039.html 一,静态库和动态库的区别在这里就不说了,个人感觉如果是自己封装提供别人下载的话应该是静态库比较方 ...

  3. 前端路由以及浏览器回退,hash & history & location

    一.前言 其实不止一次想监听浏览器的回退方法,比如 在 list.html 页滚动加载了几页列表,点到 detail.html 看详情,反回来时又得重新加载几页 H5 有背景音乐的,跳页就得重新放,体 ...

  4. MySQL备份与恢复-innobackupex

    :上一片myloder搞崩溃,为什么百度的博文都是抄袭一模一样的,哎烦! 这一片文章我们来介绍物理备份工具xtracebackup! 首先是安装可以percona官网下载安装,下载rpm包直接yum安 ...

  5. 使用 Vue.js 结合bootstrap 实现的分页控件

    原文链接:http://blog.csdn.net/qiuhaotc/article/details/53031884 源码下载: http://pan.baidu.com/s/1i4XgH6H 密码 ...

  6. linux内核分析 第7章读书笔记——《深入理解计算机系统》

    第七章 链接 --<深入理解计算机系统> 链接是将各种代码和数据部分收集起来并组合成为一个单一文件的过程,这个文件可被加载(或拷贝)到存储器并执行. 一.编译器 大多数编译系统提供编译驱动 ...

  7. scp命令在linux间传送文件的方法

    当两台LINUX主机之间要互传文件时可使用SCP命令来实现,建立信任关系之后可不输入密码. 把你的本地主机用户的ssh公匙文件复制到远程主机用户的~/.ssh/authorized_keys文件中  ...

  8. Python3基础 list remove 删除元素

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

  9. 乘积最大|2018年蓝桥杯B组题解析第十题-fishers

    标题:乘积最大 给定N个整数A1, A2, ... AN.请你从中选出K个数,使其乘积最大. 请你求出最大的乘积,由于乘积可能超出整型范围,你只需输出乘积除以1000000009的余数. 注意,如果X ...

  10. 小Z的袜子(莫队分块)题解

    小Z的袜子(hose) 作为一个生活散漫的人,小Z每天早上都要耗费很久从一堆五颜六色的袜子中找出一双来穿.终于有一天,小Z再也无法忍受这恼人的找袜子过程,于是他决定听天由命……具体来说,小Z把这N只袜 ...