menu={
"北京":{
"朝阳":{...},
"昌平":{
"沙河":{
"老男孩":{},
"阿泰包子":{},
},
"天通苑":{...},
"回龙观":{},
},
"海淀":{...},
},
"上海":{...},
"山东":{...},
}
current_layer = menu
parent_layers =[]
while True:
for key in current_layer:
print(key)
choice = input(">>>:").strip()
if len(choice) ==0:continue
if choice in current_layer:
parent_layers.append(current_layer)
current_layer =current_layer[choice]
elif choice == "b":
if parent_layers:
current_layer = parent_layers.pop()
else:
print("无此项")
print("请重新输入")