from:https://blog.csdn.net/u012412259/article/details/53175473
1. 获取两个list 的交集
-
- a=[2,3,4,5]
- b=[2,5,8]
- tmp = [val for val in a if val in b]
- print tmp
-
-
-
- print list(set(a).intersection(set(b)))
2. 获取两个list 的并集
- print list(set(a).union(set(b)))
3. 获取两个 list 的差集
- print list(set(b).difference(set(a)))