三级菜单,这个是傻瓜繁琐型

 1 menu={
 2     'beijing':{
 3         'dongcheng':{
 4             'chaoyangmen':(),
 5             'dongsi':(),
 6         },
 7         'chongwen':{
 8             'beijingzhan':(),
 9             'tiantan':(),
10         },
11         'tongzhou':{
12             'yongshun':(),
13             'xinhuadajie':()
14         }
15     },
16     'shanghai':{
17         'minhang':{
18             'lujiazui':()
19         },
20         'pudong':{
21             'dongfangmignzhu':()
22         }
23     },
24     'tianjin':{
25         'binhaixinqu':{
26             'cangku':()
27         },
28         'hexi':{
29             'shichang':()
30         }
31     }
32 }
33 simple=False
34 while not simple:
35     for key in menu:
36         print(key)
37     choice1=input('选择城市:').strip()
38     if choice1=='quit':
39         break
40     if choice1=='back':
41         continue
42     if choice1 in menu:
43         while not simple:
44             for key2 in menu[choice1]:
45                 print(key2)
46             choice2=input('选择区县:').strip()
47             if choice2=='quit':
48                 simple=True
49             if choice2=='back':
50                 break
51             if choice2 in menu[choice1]:
52                 while not simple:
53                     for key3 in menu[choice1][choice2]:
54                         print(key3)
55                     choice3=input('选择地点:').strip()
56                     if choice3=='quit':
57                         simple=True
58                     if choice3=='back':
59                         break
60                     if choice3 in menu[choice1][choice2]:
61                         print(choice3.upper(),'欢迎你')
62                     else:
63                         print('没有选项')
64             else:
65                 print('没有选项')
66     else:
67         print('没有选项')
原文地址:https://www.cnblogs.com/xusuns/p/8032518.html