结果保存在result.txt文档内
# -*- coding: utf-8 -*-
import jieba
import sys
from collections import Counter
import jieba.analyse
filename="招聘分析.txt"
def fenci(filename) :
f = open(filename,'r+')
file_list = f.read()
f.close()
seg_list = list(jieba.cut(file_list,cut_all=True))
tf={}
for seg in seg_list :
#print seg
seg = ''.join(seg.split())
if (seg != '' and seg != "
" and seg != "
") :
if seg in tf :
tf[seg] += 1
else :
tf[seg] = 1
f = open("result.txt","w+")
for item in tf:
#print item
f.write(item+" "+str(tf[item])+"
")
f.close()
fenci(filename)
https://study.163.com/provider/400000000398149/index.htm?share=2&shareId=400000000398149(博主视频教学主页)
