python三级菜单

#!/usr/bin/env python

# -*- coding:utf-8 -*-

# Author:Huajia

# meum 菜单,定义一个名为meum的菜单

meum = {

    "北京":{

        "朝阳":{

            "国贸":["建外soho","嘻嘻"],

            "奥林匹克公园":["鸟巢","水立方"],

            "十八里店":["王村路","东方盛泽之家"]

        },

        "海淀":{

            "上地":["上地三街","上地五街"],

            "菊园":["奔驰","宝马"]

        }

    },

    "江苏":{

        "苏州":{},

        "宿迁":{},

        "南京":{}

    },

    "河北":{

        "沧州":{},

        "承德":{},

        "石家庄":{}

    }

}

while not False:

    for m1 in meum:

        print(m1)

    choice1 = input("选择进入菜单(按q退出系统):")

    if choice1 in meum:

        while not False:

            for m2 in meum[choice1]:

                print("\t",m2)

            choice2 = input("选择进入菜单(按q退出系统,b返回上级菜单):")

            if choice2 in meum[choice1]:

                while not False:

                    for m3 in meum[choice1][choice2]:

                        print("\t\t",m3)

                    choice3 = input("选择进入菜单(按q退出系统,b返回上级菜单):")

                    if choice3 in meum[choice1][choice2]:

                        while not False:

                            for m4 in meum[choice1][choice2][choice3]:

                                print("\t\t\t",m4)

                            choice4 = input("最后一层菜单(按q退出系统,b返回上级菜单):")

                            if choice4 == 'q':

                                exit()

                            elif choice4 == 'b':

                                break

                    if choice3 == 'q':

                        exit()

                    elif choice3 == 'b':

                        break

            if choice2 == 'q':

                exit()

            elif choice2 == 'b':

                break

    if choice1 == 'q':

        exit()

    else:

        print("输入有误!请重新输入!")

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容