标签:key items ted 转化 int value lambda sorted and
from random import randint
d = {x: randint(60, 100) for x in ‘xyzabcd‘}
‘‘‘第一种方法使用zip()方法将字典转化为元组‘‘‘
d2 = zip(d.itervalues(), d.iterkeys())
print sorted(d2)
‘‘‘第二种方法sorted的key参数‘‘‘
d3 = d.items()
print sorted(d3, key= lambda x:x[1])
标签:key items ted 转化 int value lambda sorted and
原文地址:http://www.cnblogs.com/misslin/p/6689518.html