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("输入有误!请重新输入!")

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

推荐阅读更多精彩内容

  • rljs by sennchi Timeline of History Part One The Cognitiv...
    sennchi阅读 12,150评论 0 10
  • 要求:1.打印市、区、街道三级菜单 2.按b可随时返回上一级3.按q可随时退出程序 dict={'北京':{'...
    码力阅读 3,276评论 0 1
  • Python 面向对象Python从设计之初就已经是一门面向对象的语言,正因为如此,在Python中创建一个类和对...
    顺毛阅读 9,667评论 4 16
  • 城市里的灯塔 守候着繁华 黑土地上 盛开着野菊花 离开吧,离开吧 我们本来流浪
    独居思绪阅读 1,202评论 2 1
  • 努力一定能看得见,但不努力的人永远不会活的坦然自若๛ก你让我失望,李婧如 加油吧,希望你能醒悟
    来日方长喔阅读 2,586评论 0 0