python set 的与或非
2010-09-03 11:44
211 查看
def intersect(a, b):
""" return the intersection of two lists """
return list(set(a) & set(b))
def union(a, b):
""" return the union of two lists """
return list(set(a) | set(b))
def difference(a, b):
""" show whats in list b which isn't in list a """
return list(set(b).difference(set(a)))
""" return the intersection of two lists """
return list(set(a) & set(b))
def union(a, b):
""" return the union of two lists """
return list(set(a) | set(b))
def difference(a, b):
""" show whats in list b which isn't in list a """
return list(set(b).difference(set(a)))
相关文章推荐
- Python集合(set)类型的操作
- How to use SET in python
- Python---set
- python ,__set__, __get__ 等解释
- Python基础 -- 02 基础语法(字符串、列表、元组、字典、set集合)
- Python内置类型——set
- python 类型之 set
- Python之set
- 廖雪峰python学习笔记3:dec和set
- 【Python系列5】set和list的妙用
- Recipe 1.8. Checking Whether a String Contains a Set of Characters(Python Cookbook)
- python中list、tuple和set的基础知识(一)
- Python--Python 集合set()添加删除、交集、并集、集合
- python ---- set
- python中set和frozenset方法和区别
- Python标准库:内置函数set([iterable])
- python-set
- [Python]第八讲:dict与set
- Python学习笔记之dict、set
- 【LeetCode with Python】 Set Matrix Zeroes