Python 程序
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Python 程序相关的知识,希望对你有一定的参考价值。
Python 程序程序代码
F = "speech.txt"
numTen =[]
dict1 =
with open(F) as f:
for line in f:
numTen.extend( str(i) for i in line.split())
f.close
for item in set(numTen):
numTen.reverse()
L1=[numTen.count(item)]
dict1.update(item:L1)
print('单词共有:%s个'%len(dict1))
so=sorted(dict1.items(),key=operator.itemgetter(1))
so.reverse()
print('单词出现次数前10名分别是:')
print(so[:10]) 参考技术A 英文的话,按空格分割,中文用jieba分词 参考技术B 回国
以上是关于Python 程序的主要内容,如果未能解决你的问题,请参考以下文章