how to convert list of dict to dict

后端 未结 8 832
执笔经年
执笔经年 2020-12-12 19:00

How to convert list of dict to dict. Below is the list of dict

data = [{\'name\': \'John Doe\', \'age\': 37, \'sex\': \'M\'},
        {\'name\': \'Lisa Simp         


        
8条回答
  •  甜味超标
    2020-12-12 19:23

    The best approach would be dict((key, val) for k in data for key, val in k.items())

提交回复
热议问题