1-intersection(&)

s1.intersection(s2),返回s1和s2中相同部分,等价的运算符为 &.

60-python基础-python3-集合-集合常用方法-交集、并集、差集、对称差集-intersection(&)-union(|)-difference(-)-symmetric_difference()

 

2-union(|)

s1.union(s2)  :返回一个新集合,新集合包含s1,s2的所有元素,等价的运算符为 | 。

60-python基础-python3-集合-集合常用方法-交集、并集、差集、对称差集-intersection(&)-union(|)-difference(-)-symmetric_difference()

 

3-difference(-)

s1.difference(s2):返回的集合为s1中去除含有的s2中的元素,等价的运算符为 -。

60-python基础-python3-集合-集合常用方法-交集、并集、差集、对称差集-intersection(&)-union(|)-difference(-)-symmetric_difference()

 60-python基础-python3-集合-集合常用方法-交集、并集、差集、对称差集-intersection(&)-union(|)-difference(-)-symmetric_difference()

 

4-symmetric_difference()

s1.symmetric_difference(s2),返回两个集合中不重复的元素集合,即会移除两个集合中都存在的元素.

60-python基础-python3-集合-集合常用方法-交集、并集、差集、对称差集-intersection(&)-union(|)-difference(-)-symmetric_difference()

 

相关文章:

  • 2021-09-27
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-25
猜你喜欢
  • 2021-10-23
  • 2021-09-02
  • 2021-12-25
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案