字典 三級菜單
阿新 • • 發佈:2018-10-08
input col author clas 國漫 世界 pri 類型 dict
1 #!-*- coding:utf-8 -*- 2 # Author:Steve 3 4 dict={‘TV‘: 5 {‘動漫‘:{ 6 ‘日漫‘:[‘海賊王‘,‘龍珠‘], 7 ‘國漫‘:[‘秦時明月‘,‘畫江湖‘] 8 }, 9 ‘科教‘:{ 10 ‘動物‘:[‘動物世界‘,‘人與自然‘], 11 ‘科技‘:[‘探索與發現‘,‘科學技術探索‘] 12 }13 } 14 } 15 16 exit_flag=False 17 18 while not exit_flag: 19 for i in dict: 20 print(i) 21 choice1=input("請輸入你想收看的頻道:(按Q退出)\n") 22 if choice1 in dict: 23 while not exit_flag: 24 for i2 in dict[choice1]: 25 print(‘\t‘,i2) 26 choice2=input(‘請輸入您想收看的類型: (按B返回,按Q退出)\n‘) 27 if choice2 in dict[choice1]: 28 while not exit_flag: 29 for i3 in dict[choice1][choice2]: 30 print(‘\t\t‘,i3) 31 choice3=input(‘請輸入您想收看的節目: (按B返回,按Q退出)\n‘) 32 if choice3 indict[choice1][choice2]: 33 34 for i4 in dict[choice1][choice2][choice3]: 35 print(‘\t\t\t‘,i4) 36 choice4=input(‘這已經是最後一層了。。。 (按B返回,按Q退出)\n‘) 37 if choice4==‘B‘: 38 pass 39 elif choice4 == "Q": 40 exit_flag = True 41 if choice3 == "B": 42 break 43 elif choice3 == "Q": 44 exit_flag = True 45 if choice2 == "B": 46 break 47 elif choice2 == "Q": 48 exit_flag = True
字典 三級菜單