tag的使用

tag = True
while tag:
    print("level")
    choice = input("level>>>").strip()  #作用是暂停 不会一直死循环
    if choice == "quit":break  #终止当前循环进入到上一层
    if choice == "quit_all": tag = False  #不用一层层退出 直接退出整个循环
    while tag:
        print("level2")
        choice = input("leve2>>>").strip()
        if choice == "quit": break
        if choice == "quit_all": tag = False
        while tag:
            choice = input("leve3>>>").strip()
            if choice == "quit": break
            if choice == "quit_all": tag = False

猜你喜欢

转载自www.cnblogs.com/newt/p/9022840.html
tag