用python实现打印省、市、县三级菜单 可返回上一级 可随时退出程序


#要求:
# 打印省、市、县三级菜单
# 可返回上一级
# 可随时退出程序

# menu = {
# '北京':{
# '海淀':{
# '五道口':{
# 'soho':{},
# '网易':{},
# 'google':{}
# },
# '中关村':{
# '爱奇艺':{},
# '汽车之家':{},
# 'youku':{},
# },
# '上地':{
# '百度':{},
# },
# },
# '昌平':{
# '沙河':{
# '老男孩':{},
# '北航':{},
# },
# '天通苑':{},
# '回龙观':{},
# },
# '朝阳':{},
# '东城':{},
# },
# '上海':{
# '闵行':{
# "人民广场":{
# '炸鸡店':{}
# }
# },
# '闸北':{
# '火车战':{
# '携程':{}
# }
# },
# '浦东':{},
# },
# '山东':{},
# }
# exit_a= False
# current = menu
# gyf=[menu]
# '''
# 定义变量
# '''
#
# while not exit_a: #while 条件循环 exit—a 为真则执行for循环
# for i in current:
# print(i)
# # 用户输入 并去除空白
# choice= input('>>:').strip()
# #if判断 choice ==‘b’ 执行current gyf的列表-1
# if choice =="b":
# current=gyf[-1]
# gyf.pop()
# elif choice not in current:
# #choice 用户输入不再curent的列表里 直接跳出本次循环
# continue
# else:
# #条件不成立执行以下代码
# gyf.append(current)
# current=current[choice]
原文地址:https://www.cnblogs.com/Lollipop1/p/8041527.html