集合

定义集合:s={1,2,3,4,5}

type(s) <calss 'set'>

集合的方法:

s.add('alex'),

s.add(3),

s.clear(),

s.copy(),

s.pop()随机删,

s.remove('sb') 指定删除,没有的话会报错。

s.discard('sbbbbbb') 指定删除,没有的话不会报错

s.update([1,2,3]) update添加的都是可迭代对象

不可变集合

原文地址:https://www.cnblogs.com/jiawen010/p/9584192.html