python之路-基础篇3-创新互联
作业:
我们提供的服务有:成都网站建设、网站建设、微信公众号开发、网站优化、网站认证、红塔ssl等。为近千家企事业单位解决了网站和推广的问题。提供周到的售前咨询和贴心的售后服务,是有科学管理、有技术的红塔网站制作公司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
分享名称:python之路-基础篇3-创新互联
当前地址:http://scjbc.cn/article/didpip.html