Python 循环语句中的break和continue

简介:

while True:
print('Please input your name:')
name = input()
if name == 'kaka':
break
print('Hi,kaka')

while True:
print('who are your:')
name = input()
if name != 'Joe':
continue
print('Hello,Joe')

#当输入为kaka,循环语句中只有遇到break语句时,循环才能推出。

#当输入不是Joe,continue语句将导致程序执行跳回循环开始出。

本文转自大角牛博客51CTO博客,原文链接http://blog.51cto.com/jingshengsun888/2051630如需转载请自行联系原作者


运维的戏子

相关文章
|
5天前
|
Python
Python while 循环
Python while 循环
13 0
|
5天前
|
Python
Python基础教程——循环语句
Python基础教程——循环语句
|
6天前
|
PHP Python
最新【Python】 实现循环最快的方式_python while循环加速,2024年最新阿里php面试题
最新【Python】 实现循环最快的方式_python while循环加速,2024年最新阿里php面试题
|
5天前
|
存储 Python
Python for循环
Python for循环
14 0
|
5天前
|
Python
Python基础教程——continue语句
Python基础教程——continue语句
|
5天前
|
Python
Python基础教程——break语句
Python基础教程——break语句
|
5天前
|
Python
Python基础 笔记(六) 循环语句
Python基础 笔记(六) 循环语句
22 5
|
6天前
|
Python
2024年最新【Python】循环结构:while 循环(1),阿里巴巴面试常见问题及回答技巧
2024年最新【Python】循环结构:while 循环(1),阿里巴巴面试常见问题及回答技巧
2024年最新【Python】循环结构:while 循环(1),阿里巴巴面试常见问题及回答技巧
|
11天前
|
机器学习/深度学习 JSON 数据库
Python每循环一次保存一次结果
Python每循环一次保存一次结果
15 1
|
11天前
|
Python 容器
Python中的for循环用法详解,一文搞定它
Python中的for循环用法详解,一文搞定它