21、python基础学习-new_three_menu
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("无此项。。。。")