fr = open('test.txt' , 'r',encoding='utf-8')
s = fr.read()

s=s.lower()
s=s.replace('\n',' ')
word=s.split(' ')
dic={}
keys=set(word)
for i in keys:
dic[i]=word.count(i)
wc = list(dic.items())
wc.sort(key = lambda x:x[1] ,reverse=True)
for i in range(20):
print(wc[i])

06排序输出

06排序输出

 


相关文章:

  • 2022-03-07
  • 2021-05-29
  • 2021-06-17
  • 2022-12-23
  • 2022-12-23
  • 2021-12-15
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-01-06
  • 2021-11-08
  • 2022-01-17
  • 2022-02-01
  • 2021-09-09
  • 2022-12-23
相关资源
相似解决方案