f = open('C:\Users\Administrator\Desktop\s.txt', 'r', encoding='utf-8')
a = f.read()
d = {}
h = '''.'!?:,'''
danci = ['the', 'and', 'a']
for j in h:
b = set(a.replace("'", "").lower().split())
for v in b:
d[v] = a.count(v)
for ec in danci:
d.pop(ec)
e = list(d.items())
e.sort(key=lambda x: x[1], reverse=True)
for k,v in enumerate(e):
if k < 20:
print(v)

综合练习 词频统计

相关文章:

  • 2021-12-21
  • 2021-12-06
  • 2021-12-04
  • 2021-05-07
猜你喜欢
  • 2022-01-03
  • 2021-12-26
  • 2021-08-18
  • 2022-12-23
  • 2022-12-23
  • 2021-07-01
相关资源
相似解决方案