要求:

多级菜单

  • 三级菜单

  • 可依次选择进入各子菜单

  • 所需新知识点:列表、字典

__author__ = 'Administrator'
#!usr/bin/evn python
#-*-coding utf-8  -*-

contry = {
    "山东":{
        "济南":["历城区","历下区"],
        "青岛":["市南区","市北区","黄岛区"]
    },
    "河南":{
        "郑州":["中原区","金水区","高新区"],
        "信阳":["浉河区","平桥区","息县"]
    },
    "河北":{
        "石家庄":["新华区","桥西区","长安区"],
        "保定市":["竞秀区","莲池区","满城区"]
    }
}
#新增或者修改键值
contry["陕西"]={"西安":["灞桥区","长安区","鼓楼区"],"咸阳":[],"宝鸡":[]}
contry["陕西"]["宝鸡"]=["渭滨区","金台区","陈仓区"]

while True:
    #列出所有的省份
    for i in  contry:#取键值
        print(i.center(20,"-"))

    province = input("如果继续请输入你要查询的省\n如果退出请输入Q\n@@请输入:")
    #列出所查询的市
    if province in contry:
        for j in contry[province]:
            print(j)
    else:
        break
    select = input("如果返回上一次请输入Q,\n继续请输入城市名字\n@@请输入:")
    if select == "Q":
        print("退出")
        continue
    else:
        if len(contry[province][select])> 0:
            for area in contry[province][select]:
                print(area)
        else:
            print("………信息不全,请等待更新…………")
        if input("是否继续查询:")=="是":
            continue
        else:
            break