第一期 Python 程式設計入門共學營作業任務七


今天要跟大家介紹 Python dict 物件的一個方法 dict.items()

*Return a new view of the dictionary’s items ((key, value) pairs). See the documentation of view objects.*

這個方法將傳回dict物件的所有項目(包括key,value成對)的新的view
下列範例

languages = {'Python': 12, 'Java': 3, 'C': 2}
# dict_items([('Python',12), ('Java',3), ('C',2)])
languages.items()
  • 程式設計實作題
    你今天是一家知名電商的網站工程師,你從 Server download 了一段 log 檔案(ip 用 , 分隔),裡面有一串 IP 位址,請你印出這個 log 檔案中共有多少不重複的瀏覽 IP?
    以下是 log 範例檔案:
    raw_log_file = '128.90.16.86,186.182.189.72,70.25.134.67,153.40.249.245, 58.246.211.25,128.90.16.86,186.182.189.72,170.25.134.67, 10.40.249.245,58.246.211.25'
    
    https://repl.it/@kevinlo88/python-basic-hw07
#第一期Python程式設計入門共學營






你可能感興趣的文章

曼陀號領航計畫(3) Meeting

曼陀號領航計畫(3) Meeting

The prototype chain in JavaScript

The prototype chain in JavaScript

COSCUP 2021 筆記

COSCUP 2021 筆記






留言討論