day2-三级菜单

Posted a10086

tags:

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

 

#!/usr/bin/env python

data = {
    北京:{
        "昌平":{
            "望京1": {"奔驰", "默默"},
            "国贸2": ("cicc", "HP"),
        },
        "朝阳":{
            "望京1":{"奔驰","默默"},
            "国贸1":("cicc","HP"),
        },
    },
    山东:{
        "昌平": {
            "望京1": {"奔驰", "默默"},
            "国贸2": ("cicc", "HP"),
        },
        "朝阳": {
            "望京2": {"奔驰", "默默"},
            "国贸2": ("cicc", "HP"),
        },
    },
    广东:{
        "昌平": {
            "望京1": {"奔驰", "默默"},
            "国贸2": ("cicc", "HP"),
        },
        "朝阳": {
            "望京3": {"奔驰", "默默"},
            "国贸4": ("cicc", "HP"),
        },
    },
}
quit_q=""
while quit_q!=q:
    for i1 in data:
        print(i1)
    choice1=input("选择进入,按b返回,按q退出>>:")
    quit_q=choice1
    if choice1== b:
        break
    if choice1 in data:
        while quit_q!=q:
            for i2 in data[choice1]:
                print("	",i2)
            choice2 = input("选择进入,按b返回,按q退出>>:")
            quit_q = choice2
            if choice2 == b:
                break
            if choice2 in data[choice1]:
                while quit_q!=q:
                    for i3 in data[choice1][choice2]:
                        print("		", i3)
                    choice3 = input("选择进入,按b返回,按q退出>>:")
                    quit_q = choice3
                    if choice3 == b:
                        break
                    if choice3 in data[choice1][choice2]:
                        while quit_q != q:
                            for i4 in data[choice1][choice2][choice3]:
                                print("			", i4)
                            choice4 = input("最后一层,按b返回,按q退出>>:")
                            quit_q = choice4
                            if choice4 == b:
                                break

 

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

Python之路 day2 字典练习题之 三级菜单

Day2课后作业:三级菜单简单版

python 三级菜单 while循环三次,湖北省市-县-街道的选择,3个while的循环 -day2

Python day2_17-9-11

day2

day2