3 回答
TA贡献1846条经验 获得超7个赞
list = [{'key': 'firebase_screen_class', 'value': 'MainViewController'},
{'key': 'firebase_event_origin', 'value': 'auto'},
{'key': 'firebase_screen_id', 'value': '81265142482196321'},
{'key': 'engagement_time_msec', 'value': '3374'}]
result = dict()
for d in list:
result[d['key']] = d['value']
TA贡献1807条经验 获得超9个赞
你可以简单地使用 for 循环来做到这一点:
l1 = [{'key': 'firebase_screen_class', 'value': 'MainViewController'},
{'key': 'firebase_event_origin', 'value': 'auto'},
{'key': 'firebase_screen_id', 'value': '81265142482196321'},
{'key': 'engagement_time_msec', 'value': '3374'}]
final_dict = {}
for d1 in l1:
final_dict[d1['key']] = d1['value']
print final_dict
添加回答
举报