zoukankan      html  css  js  c++  java
  • 三级菜单

    The following code is 3 level menu, which is based on the list. But there is still some errors I can't fix them: we can't go back main menu by pressing "b", even this command doesn't exist, I don't know if it is PyCharm's problem. I wii try to fix them later.

    #多级字典及嵌套操作

    city_province = {

    "SiChuan" : {
    "ChengDu": {
    "JingJiangQu": ["银石广场", "春熙路"],
    "WuHouQu": ["武侯祠"]

    },
    "MianYang":["345"],
    "DeYang":["678"],
    "LuZhou":["789"],
    "PanZhiHua":["91011"],
    "LeShan":["101112"],
    "GuangAn":["111213"]
    },
    "GuiZhou": {
    "GuiYang": ["123"],
    "ZunYiShi": ["234"],
    "AnShunShi": ["345"],
    "FuQuanShi": ["456"],
    "KaiLiShi": ["567"],
    "XingYiShi": ["678"]
    },
    "YunNan": {
    "KunMing": ["123"],
    "QuJing": ["234"],
    "YuXi": ["345"],
    "BaoShan": ["456"],
    "LiJiang": ["567"],
    "PuEr": ["678"],
    "XuanWei": ["789"]
    }


    }

    # print(city_province["YunNan"]["KunMing"][0])
    # print(city_province.values())
    # print(city_province.keys())

    while True:
    for index, i in enumerate(city_province):
    print(index, i)

    choice = input("input your province: ")
    if choice in city_province:
    while True:
    for i2 in city_province[choice]:
    print(" ", i2)
    choice_2 = input("input your city:")
    if choice_2 in city_province[choice]:
    while True:
    for i3 in city_province[choice][choice_2]:
    print(" ", i3)
    choice_3 = input("input your choice to get more details: ")
    if choice_3 in city_province[choice]:
    for i4 in city_province[choice][choice_2][choice_3]:
    print(" ", i4)
    choice_4 = input("press b to go back the main menu: ")
    if choice_4 == "b":
    pass
    if choice_3 == "b":
    break
    if choice_2 == "b":
    break
  • 相关阅读:
    Jquery简略API使用
    JS全部API笔记
    实现nginx的负载均衡和反向代理
    HashMap在Java1.7与1.8中的区别
    数据库设计三大范式
    Java集合
    Object类有哪些方法
    spring mvc出现 Failed to convert property value of type 'java.lang.String' to required type 'java.util.Date' for property 'endtime'
    int和Integer的区别
    第二次面试-科大讯飞(卒)
  • 原文地址:https://www.cnblogs.com/charlieyucao/p/8340637.html
Copyright © 2011-2022 走看看