how to uniqify a list of dict in python

后端 未结 6 1873
长发绾君心
长发绾君心 2020-12-10 01:10

I have a list:

d = [{\'x\':1, \'y\':2}, {\'x\':3, \'y\':4}, {\'x\':1, \'y\':2}]

{\'x\':1, \'y\':2} comes more than once I want

6条回答
  •  醉酒成梦
    2020-12-10 01:37

    Another dark magic(please don't beat me):

    map(dict, set(map(lambda x: tuple(x.items()), d)))
    

提交回复
热议问题