我有一个字典项列表如下:
[{'answer_type': 'Yes', 'answer__count': 5}, {'answer_type': 'No',
'answer__count': 3}, {'answer_type': 'Maybe', 'answer__count': 2}]
我希望你能将其转换为以下形式:
[{'Yes': 5}, {'No': 3}, {'Maybe': 2}]
我知道可以循环遍历字典,提取我想要的条目并创建一个新的字典,但我想知道是否有更优雅的方式。如何高效地进行此转换?谢谢。
answer__count
,而不是一个。 - Sean Breckenridge