Possible Duplicate:
Reading a File into a Dictionary And Keeping Count從文件創建字典
我想創建帶有兩個值的字典:第一個值是文本:
<NEW ARTICLE>
Take a look at
what I found.
<NEW ARTICLE>
It looks like something
dark and shiny.
<NEW ARTICLE>
But how can something be dark
and shiny at the same time?
<NEW ARTICLE>
I have no idea.
,第二個值是多少次的計數使用詞「ARTICLE>」。
我嘗試了不同的方法,一個方法我收到此錯誤:
我收到的erorr是這樣的:
(key, val) = line.split()
ValueError: need more than 1 value to unpack
我已經嘗試了幾種不同的方法,但都無濟於事,一個方法我試圖說,它提供了太多的值來解壓縮..
我希望能夠搜索字典中的關鍵字,並找到適當的計數。
使用Python 3
你問了同樣的問題[h ERE](http://stackoverflow.com/questions/13115214/reading-a-file-into-a-dictionary-and-keeping-count)。通常不是一個好主意 – inspectorG4dget