Supposons que ce qui suit apparaisse. Je veux rendre cela unique.
>>> d = [{'x':1, 'y':2}, {'x':3, 'y':4}, {'x':1, 'y':2}]
>>> [dict(y) for y in set(tuple(x.items()) for x in d)]
[{'y': 4, 'x': 3}, {'y': 2, 'x': 1}]
http://stackoverflow.com/questions/6280978/how-to-uniqify-a-list-of-dict-in-python
Recommended Posts