📜  python Sorted Word frequency count - Python 代码示例

📅  最后修改于: 2022-03-11 14:46:32.995000             🧑  作者: Mango

代码示例1
>>> # Tally occurrences of words in a list
>>> from collections import Counter
>>> cnt = Counter()
>>> for word in ['red', 'blue', 'red', 'green', 'blue', 'blue']:
...     cnt[word] += 1
>>> cnt
Counter({'blue': 3, 'red': 2, 'green': 1})