1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/python3.6
# coding:utf-8
data = {
"北京":{
"昌平区":{"回龙观":["51reboot","oldboy"],"天通苑":["我爱我家"]},
"朝阳区":{"望京":["奔驰","陌陌"],"国贸":["CICC","HP"],"东直门":["飞信"]},
"海淀区":{"中关村":["新浪"],"五道口":["搜狗"]}
},
"河南":{
"安阳":{"殷都区":["殷墟"]},
"洛阳":{"洛龙区":["龙门石窟","白马寺"]},
"郑州":{}
}
}
quit_flag = False
while not quit_flag:
for i in data:
print (i)
choice = input("请选择输入的城市>>:")
if choice in data:
while not quit_flag:
for j in data[choice]:
print ("\t",j)
choice_2 = input("请选择输入的区>>:")
if choice_2 in data[choice]:
while not quit_flag:
for k in data[choice][choice_2]:
print("\t",k)
choice_3 = input("请选择输入的地名>>:")
if choice_3 in data[choice][choice_2]:
for n in data[choice][choice_2][choice_3]:
print ("\t\t",n)
choice_4 = input("温馨提示,这已经是最后一层啦,输入exit返回上级菜单>>:")
if choice_4 == "exit":
pass
elif choice_4 == "quit":
quit_flag = True
if choice_3 == "exit":
break
elif choice_3 == "quit":
quit_flag = True
if choice_2 == "exit":
break
elif choice_2 == "quit":
quit_flag = True
if choice == "exit":
break
elif choice == "quit":
quit_flag = True