import jiebafo = open('dopo.txt','r',encoding='utf-8').read()words = list(jieba.cut(fo))#取exp={ ',','。','!','?','?'}#列出没用的字段keys=set(words)-exp #从获取的文字中删去无用的字段dic={} #创建字典for w in keys: if len(w)>1: dic[w]=words.count[w]wc = list(dic.items()) #字典元组的列表wc.sort(key= lambda x:x[1],reverse=True) #列表排序for i in range(20): #输出top20元组 print(wc[i])