【发布时间】:2020-01-24 05:40:40
【问题描述】:
我有一本 Python 字典:
adict = {
'col1': [
{'id': 1, 'tag': '#one#two'},
{'id': 2, 'tag': '#two#'},
{'id': 1, 'tag': '#one#three#'}
]
}
我想要的结果如下:
Id tag
1 one,two,three
2 two
有人能告诉我怎么做吗?
【问题讨论】:
-
使用
for-loop 处理字典并将其转换为列表列表或新字典。 -
结果中的标签需要特殊顺序吗?
标签: python dictionary nested