标签:int 孕妇 退出 需要 class 打印 小吃 china pytho
设置三级菜单,然后选择逐级打印内容,提示选择,最后一层提示返回上一层或者退出。
‘‘‘ 三级菜单 选择进入各级 ‘‘‘ chinaMenu = { "菜谱大全":{ "家常菜谱":{ "家常菜":{"糖醋排骨","红烧排骨"}, "凉菜":{"麻辣鸡丝","凉拌黄瓜"} }, "各地小吃":{ "四川小吃":{"四川凉面","麻辣香锅"}, "广东小吃":{"鲜虾肠粉","云吞面","肉香糯米团"} } }, "健康饮食":{ "饮食健康":{ "家常菜":{"糖醋排骨","红烧排骨"}, "凉菜":{"麻辣鸡丝","凉拌黄瓜"} }, "人群膳食":{ "孕妇":{"鸽子汤","红烧猪蹄"}, "产妇":{"猪脚姜","鲫鱼汤","猪蹄花生汤"} } } } exit_flag = False while not exit_flag: for i in chinaMenu: print(i) bigMenu = input("请输入需要进入的栏目:") if bigMenu in chinaMenu: while not exit_flag: for i in chinaMenu[bigMenu]: print(i) smallMenu = input("请输入需要进入的栏目:") if smallMenu in chinaMenu[bigMenu]: while not exit_flag: for i in chinaMenu[bigMenu][smallMenu]: print(i) ultimateMenu = input("请输入需要进入的栏目:") if ultimateMenu in chinaMenu[bigMenu][smallMenu]: while not exit_flag: for i in chinaMenu[bigMenu][smallMenu][ultimateMenu]: print(i) choice = input("已经最终栏目了,请输入B返回,如果需要退出请选择Q:") if choice == "B": break if choice == "Q": exit_flag = True if ultimateMenu == "B": break if ultimateMenu == "Q": exit_flag = True if smallMenu == "B": break if smallMenu == "Q": exit_flag = True if bigMenu == "B": break if bigMenu == "Q": exit_flag = True
标签:int 孕妇 退出 需要 class 打印 小吃 china pytho
原文地址:https://www.cnblogs.com/skykylin/p/9353751.html