zoukankan      html  css  js  c++  java
  • 【Rollo的Python之路】Python:三级菜单练习

    menu = {
        "深圳":{
            "罗湖":{
                "罗湖火车站": {},
                "东门": {},
                "国贸": {},
                "布心": {},
            },
            "福田":{
                "香蜜湖": {},
                "华强北": {},
                "华强南": {},
                "市民中心": {},
            },
            "南山": {
                "南山中心城": {},
                "南头关": {},
                "华侨城": {},
            },
            "宝安": {
                "宝安中心": {},
                "西乡": {},
                "松岗": {},
            },
            "龙岗": {
                "龙岗中心城": {},
                "布吉": {},
                "坂田": {},
            },
        },
        "湖南":{
            "长沙": {
                "大学城区":{},
            },
            "衡阳":{
                "衡阳":{
                    "火车站":{},
                },
            },
            "郴州":{
                "北湖区": {},
                "苏仙区": {},
                "东湖区": {},
            },
    
        },
        "北京":{},
    }
    
    back_flag = False
    exit_flag = False
    while not back_flag and not exit_flag:
        for key in menu:
            print(key)
        choice = input("please choose the address:").strip()
        if choice in menu:
            while not back_flag and not exit_flag:
                for key2 in menu[choice]:
                    print(key2)
                choice2 = input("please choose the address").strip()
                if choice2 == "b":
                    back_flag = True
                if choice2 == "q":
                    exit_flag = True
                if choice2 in menu[choice]:
                    while not back_flag and not exit_flag:
                        for key3 in menu[choice][choice2]:
                            print(key3)
                        choice3 = input("please choose the address").strip()
                        if choice3 == "b":
                            back_flag = True
                        if choice3 == "q":
                            exit_flag = True
                        if choice3 in menu[choice][choice2]:
                            while not back_flag and not exit_flag:
                                for key4 in menu[choice][choice2][choice3]:
                                    print(key4)
                                choice4 = input("please choose the address").strip()
                                print("last layer")
                                if choice4 == "b":
                                    back_flag = True
                                if choice4 == "q":
                                    exit_flag = True
                                    break
                            else:
                                back_flag = False
                    else:
                        back_flag = False
            else:
                back_flag = False
  • 相关阅读:
    Spring集成MyBatis
    UpdatePanel的简单用法(转)
    updatePanel导致JS失效的解决办法(转)
    sql面试题(学生表_课程表_成绩表_教师表)
    javascript深入理解js闭包
    T-SQL利用Case When Then多条件判断
    T-SQL排名函数
    DataTable字符串类型的数字,按照数字类型排序
    Sql 行转列问题总结
    行转列:SQL SERVER PIVOT与用法解释
  • 原文地址:https://www.cnblogs.com/rollost/p/10730271.html
Copyright © 2011-2022 走看看