Create a three-level directory that can return to the previous directory and exit the program at any time

data = { 
'Zhejiang':{
"Shaoxing":{
"Keqiao":["A","B"],
"Shangyu":["C","D"]
},
"Hangzhou":{
"Xiaoshan ":["E","F"],
"Yuhang":{"G","H"},
"Xiasha":{"X","Y"},
},
"Wenzhou":{},
} ,
'Shandong':{
"Dezhou":{},
"Qingdao":{},
"Jinan":{}
},
'Guangdong':{
"Dongguan":{},
"Changshu":{},
"Foshan" :{},
},
}
mark=False
while not mark:
for i in data:
print (i)
choice1=input('第一层选择>>')
if choice1 in data:
while not mark:
for i in data[choice1]:
print (i)
choice2=input('第二层选择>>')
if choice2 in data[choice1]:
while not mark:
for i in data[choice1][choice2]:
print (i)
choice3=input('第三层选择>>')
if choice3 in data[choice1][choice2]:
while not mark:
for i in data[choice1][choice2][choice3]:
print (i)
choice4=input('第四层选择>>')
if choice4=='b':
break
if choice4=='q':
mark=True
if choice3=='b':
break
if choice3=='q':
mark=True
if choice2=='b':
break
if choice2=='q':
mark=True

if choice1=='b':
break
if choice1=='q':
mark=True

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325404690&siteId=291194637