方法一:
1
2
3
|
def dict_to_numpy_method1( dict ): dict_sorted = sorted ( dict .iteritems(), key = lambda d:d[ 0 ]) results = [value for key,value in dict_sorted] |
方法二:
1
2
3
4
|
def dict_to_numpy_method2( dict ): keys = dict .keys() keys.sort() results = [dic[key] for key in keys] |
方法三:
1
2
3
4
|
def dict_to_numpy_method3( dict ): keys = dict .keys() keys.sort() results = map ( dict .get,keys) |
以上这篇Python 按字典dict的键排序,并取出相应的键值放于list中的实例就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持服务器之家。
原文链接:https://blog.csdn.net/chenxieyy/article/details/53883639