#coding=utf--8 import jieba exclude={',','、','。','u3000',' ','"',"《",'》','?'} txt=open('doupo.txt','r').read() wordList=list(jieba.cut(txt)) wordSet=set(wordList)-exclude wordDict={} for w in wordSet: wordDict[w]=wordList.count(w) dictList=list(wordDict.items()) dictList.sort(key=lambda x:x[1],reverse=True) for i in range(20): print (dictList[i])