python-实现3级菜单(作业课)
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python-实现3级菜单(作业课)相关的知识,希望对你有一定的参考价值。
1 #任务: 2 #显示3级菜单 3 #1级菜单#显示 3个城市 => 1北京 2上海 3广州 4 #2级菜单 #显示 选择1 北京 => B1 B2 B3 5 #2级菜单 #显示 选择2 上海 => S1 S2 S3 6 #2级菜单 #显示 选择3 广州 => G1 G2 G3 7 8 #3级菜单 #显示 选择B1 => b1_1 b1_2 b1_3 9 #3级菜单 #显示 选择B2 => b2_1 b2_2 b2_3 10 #3级菜单 #显示 选择B3 => b3_1 b3_2 b3_3 11 12 #3级菜单 #显示 选择S1 => s1_1 s1_2 s1_3 13 #3级菜单 #显示 选择S2 => s2_1 s2_2 s2_3 14 #3级菜单 #显示 选择S3 => s3_1 s3_2 s3_3 15 16 #3级菜单 #显示 选择G1 => g1_1 g1_2 g1_3 17 #3级菜单 #显示 选择G2 => g2_1 g2_2 g2_3 18 #3级菜单 #显示 选择G3 => g3_1 g3_2 g3_3 19 20 #选择Q键 退出程序, 选择R键 返回上一级菜单 21 22 curPage = 0; #当前页数 23 minPage = 0; #最小页数 24 maxPage = 3; #最大页数 25 showVal = "1.北京 2.上海 3.广州 R.上一页 Q.退出" 26 selectVal = "北京" 27 28 while True: 29 print("-----------------------------------") 30 print("|"+showVal+"|") #显示具体内容 31 print("-----------------------------------") 32 userVal = input("input your select: ") #用户输入的值 33 34 if userVal == "Q" or userVal == "q": 35 break 36 37 if userVal == "1": 38 if curPage == 0: 39 selectVal = "北京" 40 showVal = " 1.B1 2.B2 3.B3 R.上一页 Q.退出 " 41 curPage += 1; 42 elif curPage == 1: 43 if selectVal == "北京": 44 showVal = " b1_1 b1_2 b1_3 " 45 elif selectVal == "上海": 46 showVal = " s1_1 s1_2 s1_3 " 47 elif selectVal == "广州": 48 showVal = " g1_1 g1_2 g1_3 " 49 curPage += 1; 50 elif userVal == "2": 51 if curPage == 0: 52 selectVal = "上海" 53 showVal = " 1.S1 2.S2 3.S3 R.上一页 Q.退出 " 54 curPage += 1; 55 elif curPage == 1: 56 if selectVal == "北京": 57 showVal = " b2_1 b2_2 b2_3 " 58 elif selectVal == "上海": 59 showVal = " s2_1 s2_2 s2_3 " 60 elif selectVal == "广州": 61 showVal = " g2_1 g2_2 g2_3 " 62 curPage += 1; 63 elif userVal == "3": 64 if curPage == 0: 65 selectVal = "广州" 66 showVal = " 1.G1 2.G2 3.G3 R.上一页 Q.退出 " 67 curPage += 1; 68 elif curPage == 1: 69 if selectVal == "北京": 70 showVal = " b3_1 b3_2 b3_3 " 71 elif selectVal == "上海": 72 showVal = " s3_1 s3_2 s3_3 " 73 elif selectVal == "广州": 74 showVal = " g3_1 g3_2 g3_3 " 75 curPage += 1; 76 elif userVal == "r" or userVal == "R": 77 if curPage <= 1: 78 showVal = "1.北京 2.上海 3.广州 R.上一页 Q.退出" 79 curPage = 0 80 else: 81 if selectVal == "北京": 82 showVal = " 1.B1 2.B2 3.B3 " 83 curPage -= 1; 84 elif selectVal == "上海": 85 showVal = " 1.S1 2.S2 3.S3 " 86 curPage -= 1; 87 elif selectVal == "广州": 88 showVal = " 1.G1 2.G2 3.G3 " 89 curPage -= 1; 90 else: 91 print("->没有找到对应的城市,请重新输入<-") 92 print("GAME OVER")
以上是关于python-实现3级菜单(作业课)的主要内容,如果未能解决你的问题,请参考以下文章