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
  • 相关阅读:
    windows类型
    网络编程socket、udp
    mem族函数与str族函数(待填)
    位运算符的用处(待填)
    c51较c比较,单片机最小系统
    数据结构之 顺序栈的操作
    [置顶] 数据结构之 顺序栈的操作
    java中常用的帮助类。加快开发速度
    php实现安装程序的 安装
    php压缩文件帮助类
  • 原文地址:https://www.cnblogs.com/charlieyucao/p/8340637.html
Copyright © 2011-2022 走看看