''' 程序: 三级菜单 要求: 打印省、市、县三级菜单 可返回上一级 可随时退出程序 ''' info = { '北京':{ '昌平':{ '沙河':["oldboy","test"], '天通苑':["我爱我家","链家地产"] }, '朝阳':{ '望京':["奔驰","陌陌"], '国贸':["CICC","HP"] }, '海淀':{} }, '上海':{ '浦东':[] }, '广州':{}, '深圳':{} } exit_flag = False while not exit_flag: for i in info: print(i) user_choice = input("你的选择是1>>>") if user_choice in info: while not exit_flag: for i2 in info[user_choice]: print("\t",i2) user_choice2 = input("你的选择是2>>>") if user_choice2 in info[user_choice]: while not exit_flag: for i3 in info[user_choice][user_choice2]: print("\t\t",i3) user_choice3 = input("你的选择是3>>>") if user_choice3 in info[user_choice][user_choice2]: while not exit_flag: for i4 in info[user_choice][user_choice2][user_choice3]: print("\t\t\t",i4) user_choice4 = input("最后一层,请输入“b”返回>>>") if user_choice4 == "b": break elif user_choice4 == "q": exit_flag = True elif user_choice3 == "b": break elif user_choice3 == "q": exit_flag = True elif user_choice2 == "b": break elif user_choice2 == "q": exit_flag = True elif user_choice == "b": break elif user_choice == "q": exit_flag = True
python-三级菜单
猜你喜欢
转载自blog.csdn.net/liushuichengshang/article/details/78479434
今日推荐
周排行