Python--字典(三级菜单)

   日期:2024-01-17     浏览:42    评论:0    
 1 # -*- coding:utf-8 -*-
 2 
 3 data = {
 4     "腾讯":{
 5         "LOL":{
 6             "上单":["诺手","剑姬","蛮王"],
 7             "打野":["男枪","盲僧","卡兹克"]
 8         },
 9         "CF":{
10             "步枪":[],
11             "手枪":[],
12             "机枪":[]
13         },
14         "王者":{
15             "上单":["宫本","亚瑟","项羽"],
16             "打野":["李白","兰陵王","韩信"],
17             "射手":["鲁班","后裔"]
18         }
19     },
20     "网易":{
21         "游戏1"
22     }
23 }
24 
25 exit_flag = False
26 while not exit_flag:
27     for i1 in data:
28         print(i1)
29     choice1 = input(">>>1:")
30     if choice1 in data:
31         while not exit_flag:
32             for i2 in data[choice1]:
33                 print("\t",i2)
34             choice2 = input(">>>2:")
35             if choice2 in data[choice1]:
36                 while not exit_flag:
37                     for i3 in data[choice1][choice2]:
38                         print("\t\t",i3)
39                     choice3 = input(">>>3:")
40                     if choice3 in data[choice1][choice2]:
41                         for i4 in data[choice1][choice2][choice3]:
42                             print(i4)
43                         choice4 = input(">>>4:")
44                         if choice4 == "b":
45                             pass
46                         elif choice4 == "q":
47                             exit_flag = True
48                     elif choice3 == "b":
49                         break
50                     elif choice3 == "q":
51                         exit_flag = True
52             elif choice2 == "b":
53                 break
54             elif choice2 == "q":
55                 exit_flag = True
56     elif choice1 == "q":
57         exit_flag = True
 
打赏
 本文转载自:网络 
所有权利归属于原作者,如文章来源标示错误或侵犯了您的权利请联系微信13520258486
更多>最近资讯中心
更多>最新资讯中心
0相关评论

推荐图文
推荐资讯中心
点击排行
最新信息
新手指南
采购商服务
供应商服务
交易安全
关注我们
手机网站:
新浪微博:
微信关注:

13520258486

周一至周五 9:00-18:00
(其他时间联系在线客服)

24小时在线客服