1 city = { 2 "江苏省": { 3 "南京市": { 4 "栖霞区": ["aa", "bb"], 5 "顺义区": ["cc", "dd"], 6 "普陀区": ["ee", "ff"] 7 }, 8 "南通市": { 9 "通州区": ["gg", "hh"], 10 "港闸区": ["ii", "jj"], 11 "崇川区": ["kk", "ll"] 12 }, 13 }, 14 "浙江省": { 15 "杭州市": { 16 "A区": ["mm", "nn"], 17 "B区": ["oo", "pp"] 18 }, 19 "温州市": { 20 "C区": ["qq", "rr"], 21 "D区": ["ss", "tt"] 22 } 23 } 24 } 25 current_layer = city 26 layers = [] 27 while True: 28 print("欢迎来到省市区信息管理系统".center(50, "*")) 29 for layer in current_layer: 30 print(layer) 31 choice = input("请输入你要查看的省市区信息,返回上一级按b,退出按q").strip() 32 # 查看 33 if choice in current_layer: 34 layers.append(current_layer) 35 current_layer = current_layer[choice] 36 elif choice == "b": 37 current_layer = layers.pop() 38 elif choice == "q": 39 break 40 else: 41 print("到底了!")
python3之三级菜单
猜你喜欢
转载自www.cnblogs.com/evanchenjj/p/9346290.html
今日推荐
周排行