对python列表里的字典元素去重方法详解
作者:cw-Austin 时间:2023-09-20 13:45:47
如下所示:
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'}]
来源:https://blog.csdn.net/qq_35959613/article/details/82014044
标签:python,列表,字典,去重
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
Python实现敲击木鱼积累功德小项目
2021-02-11 05:29:03
pyppeteer执行js绕过webdriver监测方法上
2021-12-13 12:04:40
浅谈pymysql查询语句中带有in时传递参数的问题
2024-01-22 02:16:32
![](https://img.aspxhome.com/file/2023/0/79750_0s.jpg)
MySQL 字符串模式匹配 扩展正则表达式模式匹配
2024-01-20 14:47:41
Python画图常用命令大全(详解)
2023-04-17 15:20:16
![](https://img.aspxhome.com/file/2023/0/110240_0s.jpg)
详细总结Python类的多继承知识
2021-10-02 03:15:02
![](https://img.aspxhome.com/file/2023/2/95412_0s.png)
20个优秀网站助你征服CSS[译]
2008-09-21 13:21:00
![](https://img.aspxhome.com/file/UploadPic/20089/21/2008921132958672s.png)
python 实现list或string按指定分段
2023-10-30 02:04:20
Git文件常用操作总结及拓展
2023-02-04 08:13:18
![](https://img.aspxhome.com/file/2023/2/131832_0s.png)
numpy数组合并和矩阵拼接的实现
2022-09-05 19:39:54
spring学习JdbcTemplate数据库事务管理
2024-01-28 10:46:13
![](https://img.aspxhome.com/file/2023/7/128827_0s.png)
SQL Server数据库管理常用SQL和T-SQL语句
2009-05-07 14:01:00
python实现爱奇艺登陆密码RSA加密的方法示例详解
2022-02-10 00:41:53
![](https://img.aspxhome.com/file/2023/9/115839_0s.jpg)
解读ASP.NET 5 & MVC6系列教程(17):MVC中的其他新特性
2023-07-11 10:44:59
Python中的list.sort()方法和函数sorted(list)
2021-07-29 17:02:23
python 性能优化方法小结
2022-08-04 21:13:43
![](https://img.aspxhome.com/file/2023/4/101114_0s.png)
vue实现移动端轻量日期组件不依赖第三方库的方法
2024-05-29 22:29:03
![](https://img.aspxhome.com/file/2023/7/123097_0s.jpg)
Python3实现的爬虫爬取数据并存入mysql数据库操作示例
2022-11-06 15:18:59
![](https://img.aspxhome.com/file/2023/1/66351_0s.png)
Excute后都需要返回一个RecordSet对象吗?
2009-10-28 18:28:00
CentOS中升级Python版本的方法详解
2021-08-22 20:22:30