Level 3 menu
实现三级菜单功能。
#!/usr/bin/env python
#-*- coding:utf-8 -*-
# Li Rong Yang
"""
This Level 3 menu.
"""
#定义字典
dic = {"山东":
{"青岛" : ['四方','黄岛','崂山','李沧','城阳'],
'济南' : ['历城','槐荫','高新','长青','章丘'],
'烟台' : ['龙口','莱山','牟平','蓬莱','招远']},
"江苏":
{"苏州" : ['沧浪','相城','平江','吴中','昆山'],
'南京' : ['白下','秦淮','浦口','栖霞','江宁'],
'无锡' : ['崇安','南长','北塘','锡山','江阴']},
"安徽":
{"安徽" : ['蜀山','庐阳','包河','经开','新站'],
'芜湖' : ['镜湖','鸠江','无为','三山','南陵'],
'蚌埠' : ['蚌山','蚌山','淮上','怀远','固镇']},
"广东":
{"深圳" : ['罗湖','福田','南山','宝安','布吉'],
'广州' : ['天河','珠海','越秀','白云','黄埔'],
'东莞' : ['莞城','长安','虎门','万江','大朗']}
}
while True:
print("----------- 中国省级地图 -----------")
for _dic in dic.keys():#打印省份
print(_dic)
province = input("Please enter the province you want to view.")
if province in dic.keys():#打印市级城市
print("----------- 中国市级地图 -----------")
for city in dic[province].keys():
print(city)
county = input("Please enter the city you want to view.")
if county in dic[province].keys():#打印县级城市
print("----------- 中国县级地图 -----------")
for _county in dic[province][county]:
print(_county)
else:
continue
user_choose = input("Do you want to return to the home page? Y over N, choose N to exit the software")
print("")
if user_choose != "Y" and user_choose != "y":
exit()

浙公网安备 33010602011771号