标签:googl menu ping 浦东 body 定义 表数据 nta pen
python三级菜单优化,菜鸟版链接:http://www.cnblogs.com/xuyaping/p/6648170.html
|
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
53
54
55
56
57
58
59
60
|
menu = { ‘北京‘:{ ‘海淀‘:{ ‘五道口‘:{ ‘soho‘:{}, ‘网易‘:{}, ‘google‘:{} }, ‘中关村‘:{ ‘爱奇艺‘:{}, ‘汽车之家‘:{}, ‘youku‘:{}, }, ‘上地‘:{ ‘百度‘:{}, }, }, ‘昌平‘:{ ‘沙河‘:{ ‘北航‘:{}, }, ‘天通苑‘:{}, ‘回龙观‘:{}, }, ‘朝阳‘:{}, ‘东城‘:{}, }, ‘上海‘:{ ‘闵行‘:{ "人民广场":{ ‘炸鸡店‘:{} } }, ‘闸北‘:{ ‘火车战‘:{ ‘携程‘:{} } }, ‘浦东‘:{}, }, ‘山东‘:{},}current_layer=menu #当前层last_layers=[menu] #上一层while True: for key in current_layer: #打印第一层菜单 print(key) choice=input(">>:").strip() #选择第二层菜单 if choice in current_layer: last_layers.append(current_layer) #进入下一层菜单前,把当前层菜单加入上一次菜单中 current_layer=current_layer[choice] #当前层菜单被重新定义,进入循环打印下一层菜单 if choice==0: #选择菜单层为空,结束本次循环 continue if choice=="q": #选择菜单层为“q”,结束本层循环 break if choice=="b": #选择菜单层为“b”,返回上一层菜单 current_layer=last_layers[-1] #返回上一层菜单前,当前层被重新定义 last_layers.pop() #删除最后一次进入下一层菜单所加入的上一层列表数据print("程序结束!") |
标签:googl menu ping 浦东 body 定义 表数据 nta pen
原文地址:http://www.cnblogs.com/c-x-m/p/7819238.html