python 列表中的字典元素去重

from functools import reduce

data_list = [{"a": "123", "b": "321"}, {"a": "123", "b": "321"}, {"b": "321", "a": "23"}]
def list_dict_duplicate_removal(data_list):

    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(data_list))

输出:


你可能感兴趣的:(python 列表中的字典元素去重)