所以我有下面的代码来计算文本文件中的字数。我想用出现次数最多的单词对输出进行排序。这如何实现?如何排序字数的输出
ally = open("alice.txt", "r")
wordcount={}
for word in ally.read().split():
if word not in wordcount:
wordcount[word] = 1
else:
wordcount[word] += 1
for k,v, in wordcount.items():
print(k,v)