Python之路 day2 字典練習題之 三級菜單

來源:互聯網
上載者:User

標籤:北京   google   print   put   while   bsp   int   百度   soho   

 1 #Author:ersa 2 ‘‘‘ 3 程式: 三級菜單 4 要求: 5 列印省、市、縣三級菜單 6 可返回上一級 7 可隨時退出程式 8 ‘‘‘ 9 menu = {10     ‘北京‘:{11         ‘海澱‘:{12             ‘五道口‘:{13                 ‘soho‘:{},14                 ‘網易‘:{},15                 ‘google‘:{}16             },17             ‘中關村‘:{18                 ‘愛奇藝‘:{},19                 ‘汽車之家‘:{},20                 ‘youku‘:{},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 is_continue = True53 while is_continue:54         for i in menu:55             print(i)56         choice = input("\t選擇進入下級菜單1>>>:")57 58         if choice in menu:59             while is_continue:60                 for i2 in menu[choice]:61                     print("\t",i2)62                 choice2 = input("\t\t選擇進入下級菜單2>>>:")63                 if choice2 in menu[choice]:64                     while is_continue:65                         for i3 in menu[choice][choice2]:66                             print("\t\t",i3)67                         choice3 = input("\t\t\t選擇進入下級菜單3>>>:")68                         if choice3 in menu[choice][choice2]:69                             while is_continue:70                                 for i4 in menu[choice][choice2][choice3]:71                                     print("\t\t\t", i4)72                                 choice4 = input("\t\t\t返回上級:b 退出:q>>>:")73                                 if choice4 == "b":74                                     break75                                 elif choice4 == "q":76                                     is_continue = False77                         if choice3 == "b":78                             break79                         elif choice3 == "q":80                             is_continue = False81                 elif choice2 == "b":82                     break83                 elif choice2 == "q":84                     is_continue = False85         elif choice == ‘b‘:86             break87         elif choice == "q":88             is_continue = False

 

Python之路 day2 字典練習題之 三級菜單

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.