模拟三级菜单

data= {
'北京':{
"昌平":{
'沙河':['oldboy','test'],
'天通苑':['链家房产','我爱我家']
},
'朝阳':{
"望京":['奔驰','陌陌'],
'国贸':['CICC','HP'],
'东直门':{'advent','飞信'},
},
'海绽':{},
},
'山东':{
"德州":{},
'青岛':{},
'济南':{},
},
'广东': {
"东莞": {},
'常熟': {},
'佛山': {},
},
}
while True:
for a in data:
print(a)
choice =input("请选择进入>>")
if choice in data:
while True:
for b in data[choice]:
print('\t',b)
choice2 = input("请选择进入2>>")
if choice2 in data[choice]:
while True:
for c in data[choice][choice2]:
print('\t\t', c)
choice3 = input("请选择进入3>>")
if choice3 in data[choice][choice2]:
while True:
for d in data[choice][choice2][choice3]:
print('\t\t', d)
choice4=input(("当前访问最后一层,输入y可返回>>"))
if choice4=='y':
break
if choice3=='y':
break
if choice2=='y':
break


猜你喜欢

转载自www.cnblogs.com/qtclm/p/9108021.html