count = 0
while count <= 5 :
count += 1
if count == 3:pass
print("Loop",count) else:
print("循环执行完啦")
print("-----out of while loop ------")

结果:

Loop 1
Loop 2
Loop 3
Loop 4
Loop 5
Loop 6
循环执行完啦
-----out of while loop ------

 count = 0
while count <= 5 :
count += 1
if count == 3:break
print("Loop",count) else:
print("循环执行完啦")
print("-----out of while loop ------")

Loop 1
Loop 2
-----out of while loop ------

结论:while循环正常执行完不会执行else里边的代码,如果while循环被break中断则会执行else里边的代码

随机推荐

  1. 转贴:天然VC的迷局

    天然VC的迷局作者:棱子 http://www.jkzgr.net/jiankangguanli/176.html 维生素C对人类来说是一种必不可少的维生素.我们可以通过正常饮食获取所需的VC.市场上 ...

  2. Android(java)学习笔记55:LayoutInflater 和 findViewById

    1. 在实际开发中LayoutInflater这个类还是非常有用的,它的作用类似于findViewById(). 不同点是LayoutInflater是用来找res/layout/下的xml布局文件, ...

  3. ACM-ICPC 2017 Asia Xi'an J LOL 【暴力 && 排列组合】

    任意门:https://nanti.jisuanke.com/t/20750 J - LOL 5 friends play LOL together . Every one should BAN on ...

  4. Codeforces Round #512 (Div. 2, based on Technocup 2019 Elimination Round 1) C. Vasya and Golden Ticket 【。。。】

    任意门:http://codeforces.com/contest/1058/problem/C C. Vasya and Golden Ticket time limit per test 1 se ...

  5. 在Spring整合aspectj实现aop的两种方式

    -----------------------------基于XML配置方案目标对象接口1 public interface IUserService { public void add(); pub ...

  6. 无法解析的外部符号 _WinMain@16,该符号在函数 ___tmainCRTStartup 中被引用

    一,问题描述MSVCRTD.lib(crtexew.obj) : error LNK2019: 无法解析的外部符号 _WinMain@16,该符号在函数 ___tmainCRTStartup 中被引用 ...

  7. 有趣的npx

    在更新 npm 5.2.0 的时候发现会买一送一,自动安装了 npx. npx 会帮你执行依赖包里的二进制文件,也就是说 npx 会自动查找当前依赖包中的可执行文件, 如果找不到,就会去 PATH 里 ...

  8. nginx 图片,js,css等文件允许跨域

    location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|mp4|ico)$ { #允许跨域请求 add_header Access-Control-Allow-Ori ...

  9. HDU1214 圆桌会议(找规律,数学)

    传送门: http://acm.hdu.edu.cn/showproblem.php?pid=1214 圆桌会议 Time Limit: 2000/1000 MS (Java/Others)    M ...

  10. 并发编程之多线程基础-join方法及优先级(五)

    join()方法作用 当在主线程当中执行到t1.join()方法时,就认为主线程应该把执行权让给t1 优先级 现代操作系统基本采用时分的形式调度运行的线程,线程分配得到的时间片的多少决定了线程使用处理 ...