Posted in Python onJanuary 21, 2019
如下所示:
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列表里的字典元素去重方法详解
- Author -
cw-Austin声明:登载此文出于传递更多信息之目的,并不意味着赞同其观点或证实其描述。
Reply on: @reply_date@
@reply_contents@