1.集合set:将不同元素组合在一起,若有相同元素只保留一个,创建方法set()

Python集合(set)

2.set去重

Python集合(set)

3.set集合对象必须是可哈希的(键值不可变的)

Python集合(set)

Python集合(set)

4.set集合是无序的

Python集合(set)


5.set集合判断

使用in 和not in 判断元素是否在集合中,是返回TRUE,不是返回FALSE

Python集合(set)

6.set()中方法

6.1.add()方法:在set集合中添加一个整体的元素内容

Python集合(set)

6.2.update()方法:在set()集合中作为一个序列将元素内容一个一个添加,支持去重

Python集合(set)


6.3.update()可添加序列,add()不可以

Python集合(set)


6.4.remove()、pop()、clear()

Python集合(set)


7.并集、交集、差集、对称差集


7.1.并集(union)或者 “|”用来表示并集

Python集合(set)


7.2.交集(intersection)或者"&"表示交集

Python集合(set)


7.3差集(diffrence)或者"-"表示差集

Python集合(set)

7.4.对称差集(symmetry_diffrence)或者"^表示对称差集"

Python集合(set)


8.父集(超集)和子集

Python集合(set)

相关文章:

  • 2021-11-11
  • 2021-10-31
  • 2021-10-05
  • 2021-10-21
  • 2021-08-06
  • 2022-02-18
猜你喜欢
  • 2021-08-24
  • 2021-11-11
  • 2021-04-08
  • 2021-10-11
  • 2021-11-08
  • 2021-12-09
  • 2021-12-09
相关资源
相似解决方案