去重 无序 没有索引
#remove 删除元素
>>> s1 = {1,2,3,4,5} >>> s1.remove(2) >>> print(s1) {1, 3, 4, 5}
#pop 剪切
>>> s1 = {1,2,3,4,5} >>> res = s1.pop() >>> print(res) 1
#add 添加
>>> s1 = {1,2,3,4,5} >>> s1.add('250') >>> print(s1) {1, 2, 3, 4, 5, '250'}
#update 添加新的元素
>>> s1 = {1,2,3,4,5} >>> s1.update('1','2','8','9') >>> print(s1) {1, 2, 3, 4, 5, '9', '1', '2', '8'}
#判断一个集合是否是另一个集合的子集
>>> s1 = {1,2,3,4,5} >>> s2 = {1,2,3} >>> res = s2.issubset(s1) >>> print(res) True
#union 并集
>>> s1 = {1,2,3,4,5} >>> s2 = {1,2,3,7} >>> print(s2.union(s1)) {1, 2, 3, 4, 5, 7}
#intersection 交集
>>> s1 = {1,2,3,4,5} >>> s2 = {1,2,3,7} >>> print(s1.intersection(s2)) {1, 2, 3}