You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
def top_danmakus(keyword_counts, top_n=8):
|
|
"""
|
|
返回出现次数最多的前N个弹幕。
|
|
:param keyword_counts: 弹幕及其出现次数的字典
|
|
:param top_n: 排行榜的长度
|
|
:return: 前N个弹幕及其出现次数
|
|
"""
|
|
sorted_counts = sorted(keyword_counts.items(), key=lambda item: item[1], reverse=True)
|
|
return dict(sorted_counts[:top_n]) |