- 输入:
[{'a': 123, 'b': 1234}, {'a': 3222, 'b': 1234}, {'a': 123, 'b': 1234}]
- 输出:
[{'a': 123, 'b': 1234}, {'a': 3222, 'b': 1234}]
- 实现代码:
[dict(t) for t in {tuple(d.items()) for d in l}]
[{'a': 123, 'b': 1234}, {'a': 3222, 'b': 1234}, {'a': 123, 'b': 1234}]
[{'a': 123, 'b': 1234}, {'a': 3222, 'b': 1234}]
[dict(t) for t in {tuple(d.items()) for d in l}]
本文标题:Python-元素为字典的列表的去重
本文链接:https://www.haomeiwen.com/subject/wjpfqctx.html
网友评论