Python:dictionary,pythondictionary

來源:互聯網
上載者:User

Python:dictionary,pythondictionary

# Python3.4 Eclipse+PyDev  開啟Eclipse,找到Help功能表列,進入Install New Software…選項。# 點擊work with:輸入框的旁邊點擊Add…,Name可以隨便是什麼,我輸入的是PyDev,Location是http://pydev.org/updates。點擊OK。import jsonimport osimport nltkimport collectionsimport heapqimport operatorimport itertoolssent=["In","the","beginning","God","created"];wo=nltk.bigrams(sent);for w in wo:    print(w);#字典      geovindu 塗聚文prices={"ACME":45.23,"APPLE":612.79,"IBM":205.55,"HP":37.20,"FB":10.67};min_prices=min(zip(prices.values(),prices.keys()));max_prices=max(zip(prices.values(),prices.keys()));sort_prices=sorted(zip(prices.values(),prices.keys()));name_prices=min(prices,key=lambda k:prices[k]);max_pricesstr=max(zip(prices.values(),prices.keys()));print("最小值對應值:"+name_prices);for mi in min_prices:    print(mi)    #print(min_prices);#print(max_prices);#print(sort_prices);print("排序:");for mis in sort_prices:    print(mis)print("最高股票:");for mix in max_prices:    print(mix)#字典中查相同點dirA={        "geovindu":32,        "塗聚文":28,        "江東":12,        "劉若英":40,        "english":22    }dirB={       "塗聚文":28,       "江蘇":32,       "劉若英":40,       "江東":12,       "geovindu":32,       "english":22        }dirkey=dirA.keys()&dirB.keys();dirvalues=dirA.items()&dirB.items();print("keys:")print(dirkey);print("values:")print(dirvalues)

  

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.