Find a given key's value in a nested ordered dict python

前端 未结 3 1991
有刺的猬
有刺的猬 2021-01-24 08:31

I am trying to find the value of a given key from a nested OrderedDict.

Key points:

  • I don\'t know how deep this dict will be nested
  • The name of t
3条回答
  •  悲&欢浪女
    2021-01-24 09:34

    You are looking for

    print [y[1] for y in mydict[x][i] if y[0] == 'powerpoint_color']
    

    This filters the deepest tuple to look for powerpoint_color in the first item, and keeps only the second one.

提交回复
热议问题