day6 三级菜单

时间:2022-12-31 16:09:08
 #__author__: Administrator
 #__date__: 2018/7/12

 china = {
     "shandong":{
         "linyi":["lanshan","nanfang","hedong"],
         "liaocheng":["liaicheng1","liaicheng2","liaicheng3"],
         "qingdao":["qingdao1","qingdao2","qingdao3"]
     },
     "hubei":{
         "wuhan":["hongshan","wuchang","hanyang"],
         "suizhou":["suizhou1","suizhou2","suizhou3"],
         "huangshi":["huangshi1","huangshi2","huangshi3"]
     },
     "guangdong":{
         "guangzhou":["guangzhou1","guangzhou2","guangzhou3"],
         "dongguan":["dongguan1","dongguan2","dongguan3"],
         "shenzhen":["shenzhen1","shenzhen2","shenzhen3"]
     }
 }
 print('中国地图'.center(30,"-"))
 for i in china:
     print(i)

 while True :

     choice = input("请输入想查看的省名[退出:q]:")
     if  choice in china:
         print(choice.center(32, "-"))
         for v in china[choice].items():
             print(v)
         choice2 = input("请输入想查看的市名[返回上级:e 退出:q]:")
         if choice2 in china[choice]:
             print(choice2.center(32, "-"))
             for i in enumerate(china[choice][choice2]):
                 print(i)
         elif choice2 == "e":
             print('中国地图'.center(30, "-"))
             for i in enumerate(china):
                     print(i)
                     break
         elif choice2 == "q":
             exit()
         else :
             print("编码不存在,请输入汉字或q!")

     elif  choice == "q":
         print("非常感谢您的使用")
         break

     else:
         print("编码不存在,请输入汉字或q!")