习题练习:
def f1(s1,s2,op=4):
if op == 1:
temp = s1.intersection(s2)
elif op == 2:
temp = s1.difference(s2)
else:
temp = s1.union(s2)
return temp
set1= set('ab')
set2 = set('cd')
print f1(set1,set2)
print f1(set1,set2,1)
print f1(set1,set2,2)
结果输出:
set(['a', 'c', 'b', 'd'])
set([])
set(['a', 'b'])