如下所示:
1
2
3
4
5
6
7
8
|
def list_dict_duplicate_removal(): data_list = [{ "a" : "123" , "b" : "321" }, { "a" : "123" , "b" : "321" }, { "b" : "321" , "a" : "123" }] run_function = lambda x, y: x if y in x else x + [y] return reduce (run_function, [[], ] + data_list) if __name__ = = '__main__' : print list_dict_duplicate_removal() |
输出结果:
1
|
[{ 'a' : '123' , 'b' : '321' }] |
以上这篇对python列表里的字典元素去重方法详解就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持服务器之家。
原文链接:https://blog.csdn.net/qq_35959613/article/details/82014044