您的位置:首页 > 编程语言 > Python开发

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)))
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: