标签:字典 port nbsp get div imp 按照字典排序 getter lam
d = {‘a‘:1,‘b‘:4,‘c‘:2}
方法一:
sorted(d.items(),key = lambda x:x[1],reverse = True)
方法二:
import operator sorted(d.items(),key = operator.itemgetter(1))
标签:字典 port nbsp get div imp 按照字典排序 getter lam
原文地址:https://www.cnblogs.com/students/p/9396151.html