b1=[1,2,3]
b2=[2,3,4]
b3 = [val for val in b1 if val in b2]
print b3 ##求交集
</pre><pre code_snippet_id="637052" snippet_file_name="blog_20150406_2_5725981" name="code" class="python">b1=[1,2,3]b2=[2,3,4]
b3 = [val for val in b1 if val not in b2]
print b3
求差集