python集合的基本操作
分类:
文章
•
2024-07-29 07:45:57
python集合的基本操作
- add():添加单个元素
- update():添加集合
- pop():弹出一个元素(由于集合是无序的所以无法指定索引进行删除)
- remove():指定删除集合中具体的元素
- clear():清空集合
- del:python内置的方法删除
- 交集(& 或者 intersection)
- 并集(| 或者 union)
- 差集(- 或者 difference)
- 反交集(^ 或者 symmetric_difference)
- 子集(< 或者 issubset)
- 超集(> 或者 issuperset)