import collections
f=open("C:/Users/86188/Desktop.txt").read()
f=f.replace(',','').replace('.','').replace('"','').replace(':','')
f=f.split()
r=collections.Counter(f)
print(r)
-----~~删除线格式~~ ----------------------------------------------------------------------
FileNotFoundError Traceback (most recent call last)
<ipython-input-9-0749d6fa5166> in <module>()
1 import collections
----> 2 f=open("C:/Users/86188/Desktop.txt").read() # 打开文档
3 f=f.replace(',','').replace('.','').replace('"','').replace(':','') # 去标点
4 f=f.split() # 单词化
5 r=collections.Counter(f) # 单词出现的频率
FileNotFoundError: [Errno 2] No such file or directory: 'C:/Users/86188/Desktop.txt'