2020310143011

import jieba
c=open(r'C:\Users\孙权宏\Desktop\《西游记》白话简写版.txt')
fenci=jieba.lcut(c.read())
a=[] #列表中分词
for word in fenci:
if len(word) == 1:
continue
else:
a.append(word)
continue
count=dict.fromkeys(a)
for i in count.keys():
count[i]=0
for j in a:
if j in count.keys():
count[j]+=1
item=list(count.items())
item.sort(key=lambda x:x[1],reverse=True)
for i in range(20):
word,count=item[i]
print("{0:<5}{1:>5}".format(word,count))

上一篇:PHP学生校园考勤管理系统,使用MYSQL数据库,增删改查


下一篇:GBase 8c部署准备(五):创建gbase用户免密登录