1 citys = {
2 '江苏省':{'南京市':['秦淮区','玄武区','浦口区']},
3 '河南省':{'郑州市':['二七区','金水区']},
4 '北京市':{'朝阳区':['朝阳区派出所'],'海淀区':['海淀区派出所']}
5 }
6
7 exit_flag = False
8 while not exit_flag:
9 for i in citys:
10 print(i)
11 choice = input("请输入你的选则1:")
12 if choice == 'q':
13 print("欢迎您下次使用!!!")
14 exit_flag = True
15 elif citys.get(choice):
16 while not exit_flag:
17 for j in citys[choice]:
18 print(j)
19 choice2 = input("请输入你的选则2:")
20 if choice2 == 'q':
21 print("欢迎您下次使用!!!")
22 exit_flag = True
23 elif choice2 == 'b':
24 break
25 elif citys[choice].get(choice2):
26 while not exit_flag:
27 for k in citys[choice][choice2]:
28 print(k)
29 choice3 = input("返回上一级菜单或者退出:")
30 if choice3 =='q':
31 print("欢迎您下次使用!!!")
32 exit_flag = True
33 elif choice3 == 'b':
34 break
35 else:
36 print("无效输入,请重新输入!!!")
37 else:
38 print("无效输入,请重新输入!!!")
39 else:
40 print("无效输入,请重新输入!!!")