20、python基础学习-three_menu

 1 #!/usr/bin/env python
 2 #__author: hlc
 3 #date: 2019/5/27
 4 
 5 
 6 menu = {
 7     '北京': {
 8         '海淀': {
 9             '五道口': {
10                 'soho': {},
11                 '网易': {},
12                 'google': {}
13             },
14             '中关村': {
15                 '爱奇艺': {},
16                 '汽车之家': {},
17                 'youku': {},
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 exit_flag = False
51 while not exit_flag :
52     for layer1 in menu :
53         print(layer1)
54     choicel1 = input("请输入:【b 返回上一层,q 退出:】一层:").strip()
55     if choicel1 in menu :
56         while not exit_flag :
57             for layer2 in menu[choicel1] :
58                 print(layer2)
59             choicel2 = input("请输入:【b 返回上一层,q 退出:】二层:").strip()
60             if choicel2 in menu[choicel1] :
61                 while not exit_flag :
62                     for layer3 in menu[choicel1][choicel2] :
63                         print(layer3)
64                     choicel3 = input("请输入:【b 返回上一层,q 退出:】三层:").strip()
65                     if choicel3 in menu[choicel1][choicel2] :
66                         while not exit_flag :
67                             for layer4 in menu[choicel1][choicel2][choicel3] :
68                                 print(layer4)
69                             choicel4 = input("请输入:【b 返回上一层,q 退出:】四层:").strip()
70                             if choicel4 == "b" :
71                                 break
72                             elif choicel4 == "q" :
73                                 exit_flag = True
74                     if choicel3 == "b":
75                         break
76                     elif choicel3 == "q":
77                         exit_flag = True
78             if choicel2 == "b":
79                 break
80             elif choicel2 == "q":
81                 exit_flag = True
82     if choicel1 == "b":
83         continue
84     elif choicel1 == "q":
85         exit_flag = True

 

posted @ 2019-05-29 08:32  hlc-123  阅读(179)  评论(0编辑  收藏  举报