1 #!/usr/bin/env python
2 #__author: hlc
3 #date: 2019/5/29
4
5 menu = {
6 '北京': {
7 '海淀': {
8 '五道口': {
9 'soho': {},
10 '網易': {},
11 'google': {}
12 },
13 '中關村': {
14 '愛奇藝': {},
15 '汽車之家': {},
16 'youku': {},
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 current_layer = menu
49 parent_layer = []
50 while True :
51 for key in current_layer :
52 print(key)
53 choice = input("input_menu_name('q'退出)>>>:").strip()
54 if len(choice) == "0" :continue
55 if choice in current_layer :
56 parent_layer.append(current_layer)
57 current_layer = current_layer[choice]
58 elif choice == "b" :
59 if parent_layer :
60 current_layer = parent_layer.pop()
61 elif choice == "q" :
62 break
63 else:
64 print("無此項。。。。")
?