Pyton 获取两个 list 的差集、并集
来源:互联网 发布:2016淘宝热卖行业 编辑:程序博客网 时间:2024/06/05 08:17
求差:
- method one:
list_one = [1, 2, 3]listd_two = [2, 3]diff = []for x in list_one: if x not in list_two: diff.append(x)
- method two:
diff = [x for x in list_one if x not in list_two]
- method three:
diff = list(set(list_one)^set(list_two))
- method four:
diff = list(set(list_one).difference(set(list_two))) one中有而two中没有的
求和:
tt = list(set(list_one).union(set(list_two)))
求交:
for x in list_one: if x in list_two: jj.append(x)
阅读全文
0 0
- Pyton 获取两个 list 的差集、并集
- python两个 list 获取交集,并集,差集的方法.
- python两个 list 获取交集,并集,差集的方法
- python两个 list 获取交集,并集,差集的方法.
- python两个 list 获取交集,并集,差集的方法
- python两个 list 获取交集,并集,差集的方法
- python两个 list 获取交集,并集,差集的方法
- python两个 list 获取交集,并集,差集的方法.
- Python中list的交、并、差集获取方法
- 求两个list的差集
- python 两个list 求交集,并集,差集
- python 两个list 求交集,并集,差集
- python 两个list求取交集、并集和差集
- python--两个list 求交\并\差集
- 两个集合的交集,并集,差
- Python求两个list的差集、交集与并集的方法
- Python求两个list的差集、交集与并集的方法
- Python求两个list的差集、交集与并集的方法(转)
- 为Spring Boot可执行文件制作Shell脚本
- ROI
- epoll使用方法&简单原理介绍&详细的select/poll/epoll对比
- curl表单
- 设置windowCloseOnTouchOutside让startActivityForResult接收传值的问题
- Pyton 获取两个 list 的差集、并集
- 排队预测标签
- 004_JS基本语法
- 数据冒险之二叉树(链表实现)
- 微信小程序入门示例
- 代码优化:SessionFactory过期项
- 在K8s中创建StatefulSet
- ios 消息转发机制
- Swift系列之——UISearchBar的简单使用