python 集合 set

特点:无序且不重复
作用:用不重复的特点去重

1、声明字典
python 集合 set
2、应用
将一个列表快速去重
python 集合 set
python 集合 set
3、增删改查
3.1、增 add()和 update(),结果是无序的

python 集合 set
python 集合 set
3.2、删remove()、pop()、clear()

python 集合 set
python 集合 set
**练习:产生10个不同的随机数存放在集合中,并删除一个
python 集合 set
python 集合 set

4、一些其他的符号
注:在集合中,没有+和*的操作
4.1、- 差集 和 对称差集 ^

python 集合 set

python 集合 set
python 集合 set
python 集合 set

4.2 & 交集
python 集合 set
4.3 |并集
python 集合 set
5、集合是可变对象
python 集合 set

相关文章: