a = {1, 4, 2, 3}
del a
a = {1, 4, 2, 3}
print(a.pop())
print(a.pop())
print(a)
a = {2, 3, 4}
a.remove(3)
print(a)
使用集合对象的add()方法增加一个元素
a = {3, 4}
a.add(2)
print(a)
使用clear()方法清空集合
a = {2, 3, 4}
a.clear()
print(a)
a = {1, 4, 7}
b = {3, 7, 8}
print(a | b)
a = {1, 4, 7}
b = {3, 7, 8}
print(a & b)
a = {1, 4, 7}
b = {3, 7, 8}
print(a - b)
a = {1, 4, 7}
b = {3, 7, 8}
print(a ^ b)
假设a,b是集合
a = {1, 2, 3}
b = {1, 2, 3}
c = {1, 2, 3, 4}
print(a < b)
print(a <= b)
print(c > a)
a = {x.strip() for x in (' he ', 'she ', ' I ')}
print(a)