这是刚开始写程序,三级菜单的程序基本是用字典实现,很low,以后学习了其他更好的东西,我会继续上传,然后争取在我水平高深之后,把这个简单的东西实现的狠高大上。
_author_ = "zhanzhengrecheng" data={ "陕西":{ "宝鸡":{"扶风县":["段家镇","城关镇"],}, "渭南":{}, "延安":{}, "西安":{}, }, "河北":{ "保定":{"唐县":["杨庄","黄庄"]}, "石家庄":{}, "唐山":{}, "衡水":{}, }, } exit_flag = False while not exit_flag: for i1 in data: print(i1) choice1 = input("选择进入1111>>:") if choice1 in data: while not exit_flag: for i2 in data[choice1]: print("\t",i2) choice2 = input("选择进入2222>>:") if choice2 in data[choice1]: while not exit_flag: for i3 in data[choice1][choice2]: print("\t\t",i3) choice3 = input("选择进入3333>>:") if choice3 in data[choice1][choice2]: for i4 in data[choice1][choice2][choice3]: print("\t\t\t",i4) choice4 = input("最后一层,按b返回") if choice4 == "b": pass elif choice4 =="q": exit_flag = True if choice3 == "b": break elif choice3 == "q": exit_flag = True if choice2 == "b": break elif choice2 == "q": exit_flag = True
未完待补充。。。。。。。。。。。。
时间: 2024-10-08 18:43:17