python set
x = set('asdfvcxwe');y = set('cswew');
print x ,y
print 'x - y:'
print (x - y)
print 'x | y:'
print (x | y)
print 'x & y:'
print(x & y)
output
set(['a', 'c', 'e', 'd', 'f', 's', 'w', 'v', 'x']) set(['c', 'e', 's', 'w'])
x - y:
set(['a', 'x', 'v', 'd', 'f'])
x | y:
set(['a', 'c', 'e', 'd', 'f', 's', 'w', 'v', 'x'])
x & y:
set(['c', 'e', 's', 'w'])
页:
[1]