可以这样访问计数器的最大值:
c = Counter()
c['foo'] = 124123
c['bar'] = 43
c['foofro'] =5676
c['barbar'] = 234
# This only prints the max key
print max(c), src_sense[max(c)]
# print the max key of the value
x = max(src_sense.iteritems(), key=operator.itemgetter(1))[0]
print x, src_sense[x]
如果我想要一个按降序计数的排序计数器怎么办?
我如何访问第二个最大值,或者第三个或第 N 个最大值键?