lygyh9985825 发表于 2017-4-21 10:54:23

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]
查看完整版本: python set