小编Chr*_*ams的帖子

从字典python列表中查找键的值

如何从字典列表中获取给定键的值?

mylist= [
    {
      'powerpoint_color': 'blue',
      'client_name': 'Sport Parents (Regrouped)'
    },
    {
      'sort_order': 'ascending',
      'chart_layout': '1',
      'chart_type': 'bar'
    }
]
Run Code Online (Sandbox Code Playgroud)

'mylist'中的词典数量未知,我想找到附加到键'sort_order'的值.

我失败的尝试:

for key in mylist:
    for value in key:
        print key['sort_order']
Run Code Online (Sandbox Code Playgroud)

谢谢

python dictionary list find

3
推荐指数
1
解决办法
4783
查看次数

标签 统计

dictionary ×1

find ×1

list ×1

python ×1