三级列表
初学python,小小一个初级应用。
1 data = { 2 '北京':{ 3 "昌平":{ 4 "沙河":["oldboy","test"], 5 "天通苑":["链家地产","我爱我家"] 6 }, 7 "朝阳":{ 8 "望京":["奔驰","陌陌"], 9 "国贸":{"CICC","HP"}, 10 "东直门":{"Advent","飞信"}, 11 }, 12 "海淀":{}, 13 }, 14 '山东':{ 15 "德州":{}, 16 "青岛":{}, 17 "济南":{} 18 }, 19 '广东':{ 20 "东莞":{}, 21 "常熟":{}, 22 "佛山":{}, 23 }, 24 } 25 exit_flag=False 26 while not exit_flag: 27 for i in data: 28 print(i) 29 choice=input("选择进入1>>>") 30 if choice in data: 31 while not exit_flag: 32 for j in data[choice]: 33 print("\t",j) 34 choice_two = input("选择进入2按f返回>>>") 35 if choice_two == 'f': 36 break 37 elif choice_two == 'q': 38 exit_flag = True 39 if choice_two in data[choice]: 40 while not exit_flag: 41 for f in data[choice][choice_two]: 42 print("\t\t", f) 43 choice_three = input("选择进入3按f返回>>>") 44 if choice_three == 'f': 45 break 46 elif choice_three == 'q': 47 exit_flag = True 48 if choice_three in data[choice][choice_two]: 49 while not exit_flag: 50 for g in data[choice][choice_two][choice_three]: 51 print("\t\t\t",g) 52 choice_4 = input("到底了,按f返回>>>") 53 if choice_4=='f': 54 break 55 elif choice_4=='q': 56 exit_flag=True
原作者博客链接:https://www.cnblogs.com/cgqForward