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
  • 相关阅读:
    win10安装.net 3.5无法启动服务,原因可能是已被禁用或与其相关联的设备没有启动
    配置SQL用户访问指定表,指定列
    GNU Gettext for Delphi, C++ and Kylix
    Delphi 7 中使用IdUDPServer1和IdUDPClient1控件实现通信检测
    xp不能安装NET Framework4.0解决方法
    基于TCP的Socket连接【Delphi版】
    牛客网优惠码
    GitHub基本操作
    xdb-test
    设置本地yum源
  • 原文地址:https://www.cnblogs.com/rollost/p/10730271.html
Copyright © 2011-2022 走看看