对python列表里的字典元素去重方法详解
程序员文章站
2023-11-11 20:10:28
如下所示:
def list_dict_duplicate_removal():
data_list = [{"a": "123", "b": "321"}...
如下所示:
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()
输出结果:
[{'a': '123', 'b': '321'}]
以上这篇对python列表里的字典元素去重方法详解就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持。