list里面包含dict进行去重
python3需要引用包,python2不需要引用
from functools import reduce
list_dict_data = [{'aa': '111'}, {'aa': '111'}, {'aa': '111'}, 'bb', 'bb', 'cc']
def list_dict_duplicate_removal(list_dict_data):
run_function = lambda x, y: x if y in x else x + [y]
return reduce(run_function, [[], ] + list_dict_data)
print(list_dict_duplicate_removal(list_dict_data))
#[{'aa': '111'}, 'bb', 'cc']
image.png
网友评论