三级菜单
region = {
'北京':{
'朝阳区':{
'海淀男孩'
}
},'上海':{
'浦东区':{
'花旗银行'
}
}
}
region_mirroring = region
parent_layers = []
while True:
for key in region_mirroring:
print(key)
choice = input('>>>:').strip()
if len(choice) == 0:continue
if choice in region_mirroring:
# returned_value = region_mirroring
parent_layers.append(region_mirroring)
region_mirroring = region_mirroring[choice]
elif choice == 'b':
# region_mirroring = returned_value
if parent_layers:#三元运算
region_mirroring = parent_layers.pop()
else:
print('无此项')