Python three -level menu Hidingin

2022-12-31   ES  

#!/Usr/bin/env python 
 #-*-coding = UTF-8-*- 

 zone = { 
     'Shandong': { 
         'Qingdao': ['Quartet', 'Huangdao', 'Laoshan', 'Licang', 'Chengyang'], 
         'Jinan': ['Line City', 'Huaiyin', 'High -tech', 'Evergreen', 'Zhangqiu'], 
         Yantai ': [' Longkou ',' Laishan ',' Mouping ',' Penglai ',' Zhaoyuan ']] 
     }, 
     'Jiangsu': { 
         'Suzhou': ['Canglang', 'Xiangcheng', 'Pingjiang', 'Wu Zhong', 'Kunshan'], 
         'Nanjing': ['White below', 'Qinhuai', 'Pukou', 'qia', 'Jiangning'], 
         'Wuxi': ['Chong'an', 'South Chang', 'Beitang', 'Xishan', 'Jiangyin'] 
     }, 
     'Zhejiang': { 
         'Hangzhou': ['West Lake', 'Jiang Qian', 'Xiacheng', 'Shangcheng', 'Binjiang'], 
         'Ningbo': ['Haishu', 'Jiangdong', 'Jiangbei', 'Zhenhai', 'Yuyao'], 
         'Wenzhou': ['Lucheng', 'Dragon Bay', 'Leqing', 'Ruian', 'Yongjia'] 
     }, 
     'Anhui': { 
         'Hefei': ['Shushan', 'Luyang', 'Baohe', 'Economic Development', 'New Station'], 
         'Wuhu': ['Mirror Lake', 'Jiujiang', '无 为', 'Three Mountains', 'Nanling'], 
         'Bengbu': ['Bengshan', 'Longzi Lake', 'Huai Shang', 'Huaiyuan', 'Gu Town'] 
     }, 
     'Guangdong' : { 
         'Shenzhen': ['Luohu', 'Futian', 'Nanshan', 'Baoan', 'Phuket'], 
         'Guangzhou': ['Tianhe', 'Zhuhai', 'Yuexiu', 'Baiyun', 'Huangpu'], 
         'Dongguan': ['Wancheng', 'Changan', 'Tiger Gate', 'Wanjiang', 'Dalang'] 
     } 
 } 



 DIC = ZONE #Create a dynamic dictionary 
 PARANTS = [] #Use a list to store the previous dictionary 

 While True: 
     for I in DIC: 
         Print (i) 
     Print ('{:-^30}'. FORMAT ('Exit by Q, press B back to the previous page')) 
     n = input ('Please enter the place name:'). Strip (). LOWER () 
     if n == 'q': Break 
     elif len (n) == 0: 
         Print ('Please re -enter!') 
         continue 
     Elif N in DIC: 
         While True: 
             if isInstance (DIC, List): #If the variable is list type 
                 Print ('{:!^30}'. Format ('The end')) 
                 Break 
             else: 
                 Parants.append (DIC) 
                 DIC = DIC [N] 
                 Break 
     elif n == 'b': 
         if PARANTS: 
             DIC = PARANTS.POP () 
     else: 
         Print ("{0:*^30}". Format ('Input is wrong, please select'))

source

Random Posts

Center 5.5 under the source code of LAMP environment installation PHP (PHP-5.4.8)

Caddy & GRPC (3) Add a reverse proxy plug -in to Caddy

HDU 2204 EDDY’s Hobbies (Principles) ACM

[Solution of the game that is good to understand] CodeForcess Round # 753 (div. 3)

VuForia how to play online video on iOS on iOS