课堂三级菜单

Posted GCat

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了课堂三级菜单相关的知识,希望对你有一定的参考价值。

import os



a = {
    "安徽": {
        "合肥" : {
            "合肥1":{},
            "合肥2":{},
            "合肥3":{},
            "合肥4":{},
        },
        "淮南" : {
            "淮南1":{},
            "淮南2":{},
            "淮南3":{},
            "淮南4":{},
        },
        "肥东" : {
            "肥东1":{},
            "肥东2":{},
            "肥东3":{},
            "肥东4":{},
        },
    },
    "河南": {
        "安阳" : {
            "安阳1":{},
            "安阳2":{},
            "安阳3":{},
            "安阳4":{},
        },
        "洛阳" : {
            "洛阳1":{},
            "洛阳2":{},
            "洛阳3":{},
            "洛阳4":{},
        },
        "开封" : {
            "开封1":{},
            "开封2":{},
            "开封3":{},
            "开封4":{},
        },
    },
    "河北": {
        "唐山": {
            "唐山1":{},
            "唐山2":{},
            "唐山3":{},
            "唐山4":{},
        },
        "北京": {
            "北京1":{},
            "北京2":{},
            "北京3":{},
            "北京4":{},
        },
        "天津": {
            "天津1":{},
            "天津2":{},
            "天津3":{},
            "天津4":{},
        },
    }
}

while True:
    for keys in a:
        print(keys)
    choice = input("1>>>")
    if choice in a:
        while True:
            for keys2 in a[choice]:
                print(keys2)
            choice2 = input("2>>>")
            if choice2 in a[choice]:
                while True:
                    for keys3 in a[choice][choice2]:
                        print(keys3)
                    choice3 = input("3>>>")
                    if choice3 == "返回":
                        break
                    elif choice3 == "退出":
                        exit()
            elif choice2 == "返回":
                break
            elif choice2 == "退出":
                exit()
    elif choice == "退出":
        exit()

 

以上是关于课堂三级菜单的主要内容,如果未能解决你的问题,请参考以下文章

js+数据库生成三级动态tree导航菜单

老男孩python3学习,课堂作业1.2 多级菜单查询

jquery两行代码实现侧边栏三级折叠菜单

python-三级菜单和购物车程序代码(补发)

TreeUtils工具类一行代码实现列表转树 实战Java8 三级菜单 三级分类 附视频

1-2 三级菜单