1. 程式人生 > >三級菜單的實現(python程序)

三級菜單的實現(python程序)

auth 菜單 石家莊 三級 lag code input 河北 cheng

這是剛開始寫程序,三級菜單的程序基本是用字典實現,很low,以後學習了其他更好的東西,我會繼續上傳,然後爭取在我水平高深之後,把這個簡單的東西實現的狠高大上。

_author_ = "zhanzhengrecheng"

data={
    "陜西":{
        "寶雞":{"扶風縣":["段家鎮","城關鎮"],},
        "渭南":{},
        "延安":{},
        "西安":{},
        },
    "河北":{
        "保定":{"唐縣":["楊莊","黃莊"]},
        "石家莊":{},
        
"唐山":{}, "衡水":{}, }, } exit_flag = False while not exit_flag: for i1 in data: print(i1) choice1 = input("選擇進入1111>>:") if choice1 in data: while not exit_flag: for i2 in data[choice1]: print("\t",i2) choice2
= input("選擇進入2222>>:") if choice2 in data[choice1]: while not exit_flag: for i3 in data[choice1][choice2]: print("\t\t",i3) choice3 = input("選擇進入3333>>:") if choice3 in data[choice1][choice2]:
for i4 in data[choice1][choice2][choice3]: print("\t\t\t",i4) choice4 = input("最後一層,按b返回") if choice4 == "b": pass elif choice4 =="q": exit_flag = True if choice3 == "b": break elif choice3 == "q": exit_flag = True if choice2 == "b": break elif choice2 == "q": exit_flag = True

未完待補充。。。。。。。。。。。。

三級菜單的實現(python程序)