#!/usr/bin/env python3
# -*- coding: utf-8 -*-
' a test module '
__author__ = 'Zhang Shuai'
a = [1,2,3,4]
b = [3,4,5,6]
'''
求交集
'''
#方法1
c = [i for i in a if i in b]
#方法2
c = list(set(a).intersection(set(b)))
'''
求并集
'''
c = list(set(a).union((set(b))))
'''
求差集
'''
c = [i for i in a if i not in b]+[j for j in b if j not in a]
'''
在a中不在b中
'''
c = list(set(a).difference(set(b)))
转自https://blog.youkuaiyun.com/u013061183/article/details/74340441