一个简单的Python3 三级菜单 展示

 1 #coding:utf-8
 2 
 3 '''
 4 多级菜单
 5 1.广东省三级菜单
 6 2.可依次选择进入各子菜单
 7 3.所需新知识点:列表,字典
 8 4.输入B重选
 9 5.输入Q退出
10 '''
11 
12 city = {"广东":{
13             "广州":{
14                  "天河":["五山","员村","车陂","沙河","石牌","兴华","沙东","林和","棠下"],
15                  "黄埔":["萝岗街道","夏港街道","联和街道","东区街道","永和街道","黄埔街道"],
16                  "越秀":["洪桥街道","北京街道","六榕街道","流花街道","光塔街道","人民街道","东山街道","农林街道"],
17                  "番禺":["市桥街道","桥南街道","东环街道","沙头街道","洛浦街道","大石街道"]
18                     },
19             "深圳":{
20                  "罗湖":["桂园街道","黄贝街道","东门街道","南湖街道","笋岗街道","东湖街道","莲塘街道","东晓街道","清水河街"],
21                  "福田":["上步","福田环庆","岗厦","皇岗","水围","渔农","石厦","新洲","沙尾","沙嘴","上沙","下沙","上梅林","下梅林","田面"],
22                  "南山":["南山街道","南头街道","西丽街道","沙河街道","蛇口街道","招商街道","粤海街道","桃源街道"],
23                  "龙岗":["平湖","坂田","布吉","南湾","横岗","龙城","龙岗","坪地"],
24                  "宝安":["新安街道","西乡街道","福永街道","沙井街道","松岗街道","石岩街道"]
25                     }
26             }
27 
28         }
29 
30 max_mark = "null"
31 while max_mark == "null":
32     for s in city.keys():
33         print("\n===========\n")
34         print("省份列表:")
35         print(s)
36 
37     province = input("\n[Q]退出\n请选择以上的一个省:")
38     if province == "Q":
39         max_mark = "Q"
40         break
41     print("\n%s省所属市列表:"%province)
42     for c in city[province].keys():
43         print(c)
44 
45     municipality = input("\n[Q]退出,[B]重选\n请选择以上的一个市:")
46     if municipality == "Q":
47         max_mark == "Q"
48         break
49     elif municipality == "B":
50         continue
51     print("\n%s省%s市所属区列表:"%(province,municipality))
52     for q in city[province][municipality].keys():
53         print(q)
54 
55     district = input("\n[Q]退出,[B]重选\n请选择以上的一个区:")
56     if district == "Q":
57         max_mark == "Q"
58         break
59     elif district == "B":
60         continue
61     print("\n%s省%s市%s区所属村/镇/街道列表:"%(province,municipality,district))
62     for j in city[province][municipality][district]:
63         print(j)

 

转载于:https://www.cnblogs.com/l729414559/p/6755904.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值