f=open("C:/Users/ZD/PycharmProjects/test/test.txt",'r',encoding='utf8') str=f.read() f.close() import jieba wordList=jieba.cut(str) wordList=list(jieba.cut(str)) wordDic={} for i in set(wordList): wordDic[i]=wordList.count(i) sort_word=sorted(wordDic.items(),key=lambda d:d[1],reverse=True) for i in range(20): print(sort_word[i])