作业:
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进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。