📜  python 计数字典 - Python 代码示例

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

代码示例3
most_common([n])¶
Return a list of the n most common elements and their counts from the most common to the least. If n is omitted or None, most_common() returns all elements in the counter.
Elements with equal counts are ordered arbitrarily:

>>> Counter('abracadabra').most_common(3)
[('a', 5), ('r', 2), ('b', 2)]