小实验2:三级菜单

Posted Alano的自嘲

tags:

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

# Author:Alano

city = {
    "tianjin":{
        "Hedong":{
            "shiyijinglu":{"1"},
            "ergong":{"2"},
            "haihe":{"3"},
        },
        "Hexiqu":{
            "meiling":{},
            "Meiguihuayuan":{},
            "TJtushuguan":{},
        },
        "Hebeiqu":{
            "nankoulu":{},
            "Xukai":{},
            "Zhangyi":{},
        },
        },
    "beijing":{},
    "Hebeisheng":{},
 }

while True:
    for i in city:
        print(i)
    choice = input("Do you want to go >>>")
    if choice in city:
        while True:
            for i2 in city[choice]:
                print(i2)
            choice2 = input("Do you want to go >>>")
            if choice2 in city[choice]:
                while True:
                    for i3 in city[choice][choice2]:
                        print(i3)
                    choice3 = input("Do you want to go >>>")
                    if choice3 in city[choice][choice2]:
                        for i4 in city[choice][choice2][choice3]:
                            print(i4)
                            choice4 = input("Turn Back set (q)>>>")
                            if choice4 == "q":
                                break
                    if choice3 == "q":
                        break
            if choice2 == "q":
                break
    if choice == "q":
        print("This is top!")

 

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

python很low的三级菜单

三级菜单小练习

三级菜单小程序

小程序菜单三级分类

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

python学习之路-练习小程序03(三级菜单)