【发布时间】:2020-07-06 04:31:38
【问题描述】:
datainput = {'thissong-fav-user:type1-chan-44-John': [{'Song': 'Rock',
'Type': 'Hard',
'Price': '10'}],
'thissong-fav-user:type1-chan-45-kelly-md': [{'Song': 'Rock',
'Type': 'Soft',
'Price': '5'}]}
需要输出:
{'thissong-fav-user:type1-chan-44-John': [{key:'Song',Value:'Rock'},
{key:'Type', Value:'Hard'},
{Key: 'Price', Value:'10'}],
'thissong-fav-user:type1-chan-45-kelly-md': [{key:'Song',Value:'Rock'},
{key:'Type', Value:'Soft'},
{Key: 'Price', Value:'5'}]}
我从下面开始,这给了我一个内部嵌套模式,不确定如何获得所需的输出。
temps = [{'Key': key, 'Value': value} for (key, value) in datainput.items()]
【问题讨论】:
标签: python list dictionary nested