对python列表里的字典元素去重方法详解
如下所示:
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列表里的字典元素去重方法详解就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持【听图阁-专注于Python设计】。