所以我有下面的代碼來計算文本文件中的字數。我想用出現次數最多的單詞對輸出進行排序。這如何實現?如何排序字數的輸出
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)