【发布时间】:2016-11-29 09:31:10
【问题描述】:
我有一个看起来像这样的字典列表:
[{u'control_set': {u'no_prediction': 'v1'}}
{u'control_set': {u'wrong': 'v2'}}
{u'prediction_set': {u'right': 'v4'}}
{u'prediction_set': {u'wrong': 'v3'}}]
我想把它转换成一个深度嵌套的字典:
{u'control_set' : {u'no_prediction': 'v1',u'wrong': 'v2'}
u'prediction_set' : {u'wrong' : 'v3', u'right' : 'v4'}}
看到了一些解决方案,但似乎都假设产品的深度不变,我正在寻找一般性的东西
谢谢
【问题讨论】:
-
您应该展示您尝试过的内容以及遇到的问题。 SO 不是代码编写服务。
标签: python dictionary nested