设计一个三级菜单,要求能够下钻,能够推出,比较笨的方法
# coding=utf-8
# Author: RyAn Bi
data = {
'beijing':{
'changping':{
'wudaokou':['oldboy','test'],
'sanlitun':['oldboy','test'],
'wangjing':['oldboy','test']
},
'dongcheng':{
'wudaokou':['oldboy','test'],
'sanlitun':['oldboy','test'],
'wangjing':['oldboy','test']
},
'xicheng':{
'wudaokou':['oldboy','test'],
'sanlitun':['oldboy','test'],
'wangjing':['oldboy','test']
}
},
'henan':{
'zhengzhou':{
'wudaokou':[],
'sanlitun':[],
'wangjing':[]
},
'xuchang':{
'wudaokou':[],
'sanlitun':[],
'wangjing':[]
},
'lohe':{
'wudaokou':[],
'sanlitun':[],
'wangjing':[]
}
},
'shandoong':{
'jinan':{
'wudaokou':[],
'sanlitun':[],
'wangjing':[]
},
'qingdao':{
'wudaokou':[],
'sanlitun':[],
'wangjing':[]
},
'weihai':{
'wudaokou':[],
'sanlitun':[],
'wangjing':[]
}
}
} #print( data)
exit_flag = False while not exit_flag:
for i in data:
print(i)
chose1 = input('where is your home:')
if chose1 in data:
while not exit_flag:
for i2 in data[chose1]:
print(i2)
chose2 = input('where is your home:')
if chose2 in data[chose1]:
while not exit_flag:
for i3 in data[chose1][chose2]:
print(i3)
chose3 = input('where is your home:')
if chose3 in data[chose1][chose2]:
while not exit_flag:
for i4 in data[chose1][chose2][chose3]:
print(i4)
chose4 = input('push q come back')
if chose4 == 'b':
break
elif chose4 =='q':
exit_flag = True
if chose3 == 'b':
break
elif chose3 =='q':
exit_flag = True
if chose2 == 'b':
break
elif chose2 =='q':
exit_flag = True