您好,登錄后才能下訂單哦!
作業:
1、每周寫一篇博客
2、編寫登錄接口
輸入用戶名密碼
認證成功后顯示歡迎信息
輸錯三次后鎖定
3、多級菜單
三級菜單
可依次選擇進入各子菜單
所需新知識點:列表、字典
data = { "水果":{ "香蕉":{ "產地":["海南","馬爾代夫"], "價格":[9.9,29.9] }, "蘋果":{ "產地":["美國","山東"], "價格":[1.2,5.5] }, "荔枝":{ "產地":["臺灣","云南","廣西"], "價格":[9,35,18] }, }, "蔬菜":{ "菜花":{ "產地":["河北","河南"], "價格":[25,13] }, "西紅柿":{ "產地":["懷柔","延慶"], "價格":[0.5,1] }, }, "調料":{ "醬油":{ "品牌":["海天","魯花","李錦記"], "價格":[25.5,35.5,15.5] }, "食用鹽":{ "品牌":["久大","白象"], "價格":[5,9] }, }, } while True: for i in data: print(i) choice = input("選擇進入1>>:") if choice in data: while True: for i2 in data[choice]: print("\t",i2) choice2 = input("輸入b返回上一級菜單或選擇進入2>>:") if choice2 in data[choice]: while True: for i3 in data[choice][choice2]: print("\t\t",i3) choice3 = input("輸入b返回上一級菜單或選擇進入3>>:") if choice3 in data[choice][choice2]: for i4 in data[choice][choice2][choice3]: print("\t\t",i4) choice4 = input("輸入b返回上一層,或輸入q退出>>:") if choice4 == "b": pass elif choice4 == "q": exit() if choice3 == "b": break elif choice3 == "q": exit() if choice2 == "b": break elif choice2 == "q": exit() else: print("輸入內容不存在。") break
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。