[英]Python - If given dictionary create a list of keys in order of the values
我有一個類似下面的字典。
ex1_pattern = {'ex':0,'country':1,'dow':2,'hod':3,'adx':4,'vid1':5}
我想創建一個密鑰列表,例如
ex1_pattern.keys()
但是..我希望列表按順序排列。 例如:
[ex,country,dow,hod,adx,vid1]
什么是最有效的方法呢?
sorted(ex1_pattern, key=ex1_pattern.get)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.