python流程判断之多层循环学习笔记
2017-04-16 20:31
309 查看
passwd = 'test' 创建一个变量
logout_flag = False 如果登录等于假,继续输入密码
for i in range(4): 循环4次
user_input = raw_input("please input your passwd:").strip() 赋值用户输入passwd次数
if len(user_input) == 0:continue 从0开始计入次数,continue 持续的意思
if user_input == passwd: 判断用户输入密码
while True: 如果为真则登录 选择如下选项
print "welcome login!"
user_choice = raw_input('''
1. run a cmd
2. send a file
3. exit this level
4. exit the whole system
''').strip()
user_choice = int(user_choice)
if user_choice == 1: 直到循环到4次之后推出
print "going to run cmd"
if user_choice == 2:
print "going to sed a file"
if user_choice == 3:
print "going to exit this level"
break
if user_choice == 4:
logout_flag = Ture
break break代表退出while True:循环
if logout_flag:
print "going to logout"
break break代表退出for循环
print "---going to do something else...."
logout_flag = False 如果登录等于假,继续输入密码
for i in range(4): 循环4次
user_input = raw_input("please input your passwd:").strip() 赋值用户输入passwd次数
if len(user_input) == 0:continue 从0开始计入次数,continue 持续的意思
if user_input == passwd: 判断用户输入密码
while True: 如果为真则登录 选择如下选项
print "welcome login!"
user_choice = raw_input('''
1. run a cmd
2. send a file
3. exit this level
4. exit the whole system
''').strip()
user_choice = int(user_choice)
if user_choice == 1: 直到循环到4次之后推出
print "going to run cmd"
if user_choice == 2:
print "going to sed a file"
if user_choice == 3:
print "going to exit this level"
break
if user_choice == 4:
logout_flag = Ture
break break代表退出while True:循环
if logout_flag:
print "going to logout"
break break代表退出for循环
print "---going to do something else...."
相关文章推荐
- Python学习笔记(五)——Python 判断循环语句
- python学习笔记(7):条件判断与循环
- 编程小白的第一本 python 入门书 学习笔记04 第五章 循环与判断
- python学习笔记2.3- 循环、判断
- shell编程学习笔记6--条件判断(循环)与流程控制
- python学习笔记(三)条件判断和循环
- python2.7学习笔记(4) ——条件判断、循环、dict、set
- Python学习笔记(三)—条件判断与循环
- Python 学习笔记 -- 条件判断、循环和异常处理
- 廖雪峰python学习笔记6:条件判断、循环
- python学习笔记 条件判断和循环
- Python学习笔记—条件判断和循环
- Python学习笔记_判断和循环
- Python学习笔记——判断语句和循环语句
- Python学习笔记——条件判断与循环
- Python学习笔记——条件判断与循环
- 丹的Python学习笔记Day5条件判断和循环
- Python学习笔记DAY2----判断循环
- Python3学习笔记【基础3--list,tuple,if条件判断,for/while循环,dict字典,set集合】
- Python学习笔记-Python的字符串,格式化,条件判断,循环、raw_input的注意事项