#!/usr/bin/env python
# -*- coding:utf-8 -*-
#Author: nulige tag=True #设置tag控制他,只要一输入Flash就退出整个循环
while tag:
print('level')
choice=input("levell>>: ").strip()
if choice == 'quit': break #quit 退出下一层循环,返回上一层循环
if choice == 'quit_all': tag = False #quit_all 退出所有循环
while tag:
print('leve12')
choice = input("leve12>>: ").strip()
if choice == 'quit': break
if choice == 'quit_all': tag = False
while tag:
print('level3')
choice = input("level3>: ").strip()
if choice == 'quit': break
if choice == 'quit_all': tag = False
执行结果:
level
levell>>: ss
leve12
leve12>>: ddd
level3
level3>: ccc
level3
level3>: quit
leve12
leve12>>: quit #返回上一层循环
level
levell>>: quit_all #退出所有循环