Python学习第三天——三级目录

 1 #coding=utf-8
 2 #Version:python 3.6.0
 3 #Tools:Pycharm 2017.3.2
 4 _date_ = '2018/4/17/017 10:48'
 5 _author_ = 'Hongyong'
 6 
 7 address_data = {
 8     "Hubei":{
 9         "Wuhan":{"Car"},
10         "Huanggang":{"Food"}
11     },
12     "Guangdong":{
13         "Guangzhou":{"University"},
14         "Shenzhen":{"Money"}
15     },
16     "Hongkong":{
17         "Yuanlang":{"Park"},
18         "Nanqu":{"Sea"}
19     }
20 }
21 
22 print(address_data)
23 
24 while True:
25     for i in address_data:
26         print(i)
27     choice1 = input("请选择>>> ")
28     if choice1 in address_data:
29         for i in address_data[choice1]:
30             print(i)
31         choice2 = input("请选择>>> ")
32         if choice2 in address_data[choice1]:
33             for i in address_data[choice1][choice2]:
34                 print(i)
35         elif choice2 == "b":
36             break
37             while True:
38                 choice3 = input("请选择>>> ")
39                 if choice3 in address_data[choice1][choice2]:
40                     print("已是最后一级目录,按b返回。")
41                     for i in address_data[choice1][choice2][choice3]:
42                         print(i)
43                 elif choice3 == "b":
44                     break
View Code
原文地址:https://www.cnblogs.com/yongor/p/8862535.html