Python_Example_多級選擇程式

來源:互聯網
上載者:User

標籤:pyc   flag   int   +=   lse   author   pycha   word   arm   

 2018-09-09

Author: 楚格

IDE: Pycharm2018.02   Python 3.7   

KeyWord : 字典 

Explain:

多級選擇,後續待最佳化

 

 

1------------------------------------------------------------------------------------------------------------------



--
__author__ = "chu ge"#key-valuedata = {            "歐美":{                    "www.hsbc.com"         : ["個人銀行","保險投資","借貸以及信用卡"],                    "www.citibank.com"     : ["最成功的金融服務集團","儲蓄信託證券保險"],                    "www.jpmorganchase.com": ["一家跨國金融服務中心及美國最大的銀行","投資管理"],                    "www.deutsche.com"     : ["德國最大的銀行和世界上最主要的金融機構","世界上首要的金融機構"]                  },            "日韓":{                    "BankofJapan.com":["日本最大的金融機構","個人業務"],                    "BankofHanYa.com":["韓國最大的金融機構","個人業務"]                  },            "大陸":{                    "中行":["排名第一" ,"儲蓄信託證券保險"],                    "工行":["排名第二" ,"儲蓄信託證券保險"],                    "建行":["排名第三" ,"儲蓄信託證券保險"],                    "農行":["排名第四" ,"儲蓄信託證券保險"],                    "交行":["排名第五" ,"儲蓄信託證券保險"]                  }        }print("Bank:",data)data["大陸"]["建行"][1] = "儲蓄信託證券保險,分散貨幣"  # 修改data.setdefault("大陸",{"www.baidu.com":[1,2]})print("Bank:",data)exit_flag = Falsewhile not exit_flag:    print(‘---- 首層 ----‘)    # local_a = 0    # for i in data:    #     local_a += 1    #     print(‘序號 %d  %s‘%(local_a,i))    for index, item in enumerate(data):  # enumerate 把列表下標取出來        print(index, item)               # enumerate(data) 擷取下標    index1 = input("選擇進入(內容) 1 >>>: ")    if index1 in data:        while not exit_flag:            # for i2 in data[index1]:            #     print("\t",i2)            for index, item in enumerate(data[index1]):  # enumerate 把列表下標取出來                print(index, item)  # enumerate(data) 擷取下標            index2 = input("選擇進入 2 >>>:")            if index2 in data[index1]:                while not exit_flag:                    local_a = 0                    for i3 in data[index1][index2]:                        local_a += 1                        print(‘local_a: %d ‘%local_a,"\t\t", i3)                        index3 = input("最後一層,按b返回>>:")                        if index3 == "b":                            pass                        elif index3 == "q":                            exit_flag = True            if index2 == "b":                break            elif index2 == "q":                exit_flag = True

--

---- 首層 ----0 歐美1 大陸2 日韓選擇進入(內容) 1 >>>: 大陸0 中行1 農行2 建行3 工行4 交行選擇進入 2 >>>:工行local_a: 1   排名第二最後一層,按b返回>>:

  

Python_Example_多級選擇程式

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.