标签:.so format 结果 set range print orm import form
import jieba
fr = open(‘tridebody.txt‘,‘r‘,encoding = ‘utf-8‘)
str = fr.read()
fr.close()
words = jieba.cut(str)
words = list(words)
print(‘{0:-^50)‘.format(‘分词解析成功!‘))
di = 0;
dise = set(words)
print(‘分词统计中------‘)
for i in dise:
print(i)
di[i] =words.count(i)
wc = list(di.items())
#print(wc)
wc.sort(key= lambda x:x[i],reverse = True)
#print(wc)
print(‘{0:-^50}‘.format(‘词频统计结果前10‘))
for i in range(len(dise)):
print(‘{0} = {1}‘.format(wc[i][0].wc[i][1]))
标签:.so format 结果 set range print orm import form
原文地址:http://www.cnblogs.com/-064/p/7609630.html