在Python 3.0.1中,我試圖使用collections
模塊的Counter
部分 無論我在文檔中看到什麼......都沒有說這個模塊的這部分不是在Python 3.0.1中可用。但...Python 3.0.1 collections.Counter
from collections import Counter
from collections import counter
from Collections import Counter
from Collections import counter
對我來說所有的產量錯誤......爲什麼這是???
似乎配方是爲Python 2.x編寫的,如果您在Python 3.0中使用它,則需要將所有'iteritems'函數引用替換爲'items'。 – 2012-04-05 21:10:26