我有这样的数据结构:
playlists_user1={'user1':[
{'playlist1':{
'tracks': [
{'name': 'Karma Police','artist': 'Radiohead', 'count': 1.0},
{'name': 'Bitter Sweet Symphony','artist': 'The Verve','count': 2.0}
]
}
},
{'playlist2':{
'tracks': [
{'name': 'We Will Rock You','artist': 'Queen', 'count': 3.0},
{'name': 'Roxanne','artist': 'Police','count': 5.0}
]
}
},
]
}
playlists_user2={'user2':[
{'playlist1':{
'tracks': [
{'name': 'Karma Police','artist': 'Radiohead', 'count': 2.0},
{'name': 'Sonnet','artist': 'The Verve','count': 4.0}
]
}
},
{'playlist2':{
'tracks': [
{'name': 'We Are The Champions','artist': 'Queen', 'count': 4.0},
{'name': 'Bitter Sweet Symphony','artist': 'The Verve','count': 1.0}
]
}
},
]
}
我想将两个嵌套的字典合并到一个单独的数据结构中,其第一个item
将是playlist key
,如下所示:
我试过:
^{3}$无济于事。在
我怎么解决这个问题?在
因为您的播放列表值已经是一个包含一个键的字典列表列表(如果您问我,有点模糊):
或者,如果你有很多这样的东西,列个清单:
^{pr2}$相关问题 更多 >
编程相关推荐