— 46 —
10.3Python第三方库
10.3.3 Jieba库
【例10-48】分析《淮南子原道训》文中出现频率最高的10个词语。
17 for word in excludes:
18 del (counts[word])
19 items = list(counts.items())
20 items.sort(key=lambda x: x[1], reverse=True)
21 for i in range(10):
22 word, count = items[i]
23 print('{:<10}{:>5}'.format(word, count))