本文實(shí)例講述了Python3.5實(shí)現(xiàn)的三級(jí)菜單功能。分享給大家供大家參考,具體如下:
在鄒城等地區(qū),都構(gòu)建了全面的區(qū)域性戰(zhàn)略布局,加強(qiáng)發(fā)展的系統(tǒng)性、市場(chǎng)前瞻性、產(chǎn)品創(chuàng)新能力,以專注、極致的服務(wù)理念,為客戶提供網(wǎng)站建設(shè)、網(wǎng)站設(shè)計(jì) 網(wǎng)站設(shè)計(jì)制作定制制作,公司網(wǎng)站建設(shè),企業(yè)網(wǎng)站建設(shè),成都品牌網(wǎng)站建設(shè),營(yíng)銷型網(wǎng)站建設(shè),成都外貿(mào)網(wǎng)站建設(shè),鄒城網(wǎng)站建設(shè)費(fèi)用合理。程序:三級(jí)菜單
要求:
1. 打印省、市、縣三級(jí)菜單
2. 可返回上一級(jí)
3. 可隨時(shí)退出程序
具體代碼:
#!/usr/bin/env python # -*- coding:utf-8 -*- # Author:ZhengzhengLiu Province_Data = { "北京市":{ "朝陽區(qū)":{ "南磨房地區(qū)":["東郊社區(qū)","平樂園社區(qū)"], "高碑店地區(qū)":["興隆家園社區(qū)","大黃莊社區(qū)"], "將臺(tái)地區(qū)":["麗都社區(qū)","房里苑社區(qū)"] }, "海淀區(qū)":{ "萬壽路街道":["",""], "羊坊店街道":["",""], "八里莊街道":["",""] }, "懷柔區(qū)":{ "懷柔鎮(zhèn)":["",""], "雁棲鎮(zhèn)":["",""], "城廟鎮(zhèn)":["",""] } }, "天津市":{ "和平區(qū)":{ "勸業(yè)場(chǎng)街道":["",""], "小白樓街道":["",""], "五大道街道":["",""] }, "南開區(qū)":{ "華苑街道":["",""], "長(zhǎng)虹街道":["",""], "鼓樓街道":["",""] }, "河西區(qū)":{ "桃園街道":["",""], "馬場(chǎng)街道":["",""], "大營(yíng)門街道":["",""] } }, "河北省":{ "石家莊市":{ "長(zhǎng)安區(qū)":["",""], "橋西區(qū)":["",""], "新華區(qū)":["",""] }, "廊坊市":{ "安次區(qū)":["",""], "廣陽區(qū)":["",""], "西小區(qū)":["",""] }, "唐山市":{ "路南區(qū)":["",""], "路北區(qū)":["",""], "古冶區(qū)":["",""] } }, "山東省":{ "青島市":{ "市南區(qū)":["",""], "市北區(qū)":["",""], "即墨市":["",""] }, "濟(jì)南市":{ "歷下區(qū)":["",""], "市中區(qū)":["",""], "槐蔭區(qū)":["",""] }, "煙臺(tái)市":{ "福山區(qū)":["",""], "萊山區(qū)":["",""], "牟平區(qū)":["",""] } } } exit_flag = False #退出標(biāo)志符 while not exit_flag: for i in Province_Data: print(i) user_choice = input("Please choose the province...") if user_choice in Province_Data: while not exit_flag: for j in Province_Data[user_choice]: print('\t',j) user_choice1 = input("Please choose the city...") if user_choice1 in Province_Data[user_choice]: while not exit_flag: for k in Province_Data[user_choice][user_choice1]: print('\t\t',k) user_choice2 = input("Please choose the communitiy...") if user_choice2 in Province_Data[user_choice][user_choice1]: while not exit_flag: for l in Province_Data[user_choice][user_choice1][user_choice2]: print('\t\t\t',l) user_choice3 = input("The last choose,please enter 'b' to back...") if user_choice3 == 'b': break elif user_choice3 == 'q': exit_flag = True if user_choice2 == 'b': break elif user_choice2 == 'q': exit_flag = True if user_choice1 == 'b': break elif user_choice1 == 'q': exit_flag = True #運(yùn)行結(jié)果: ''' 山東省 河北省 天津市 北京市 Please choose the province...北京市 朝陽區(qū) 懷柔區(qū) 海淀區(qū) Please choose the city...朝陽區(qū) 南磨房地區(qū) 將臺(tái)地區(qū) 高碑店地區(qū) Please choose the communitiy...將臺(tái)地區(qū) 麗都社區(qū) 房里苑社區(qū) The last choose,please enter 'b' to back...b 南磨房地區(qū) 將臺(tái)地區(qū) 高碑店地區(qū) Please choose the communitiy...b 朝陽區(qū) 懷柔區(qū) 海淀區(qū) Please choose the city...b 山東省 河北省 天津市 北京市 Please choose the province...北京市 朝陽區(qū) 懷柔區(qū) 海淀區(qū) Please choose the city...q Process finished with exit code 0 '''
文章題目:Python3.5實(shí)現(xiàn)的三級(jí)菜單功能示例-創(chuàng)新互聯(lián)
瀏覽路徑:http://jinyejixie.com/article16/dhdggg.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站改版、域名注冊(cè)、網(wǎng)站制作、商城網(wǎng)站、網(wǎng)站內(nèi)鏈、面包屑導(dǎo)航
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容