我的问题可能很容易解决,但我是一个Python初学者,不能这样做。你知道吗
b = input()
a = b.split()
from collections import Counter
myDict = Counter(a)
import operator
test_dict = myDict
wynik = sorted(test_dict.items(), key=operator.itemgetter(1))
print(wynik)
为什么wynik
没有排序?你知道吗
Tags:
您的数据已排序。按值的升序排列。如果要按降序排列计数,请使用
reverse=True
反转排序顺序:请注意,您不需要自己排序;请改用^{} method :
此方法已按降序返回键和计数:
相关问题 更多 >
编程相关推荐