首页 › 参考手册 › 集合方法 › set.intersection()

Python set.intersection() 方法

描述

返回交集,等价于 & 运算符。

语法

set.intersection(*others)

参数

参数说明
others其他集合

返回值

新集合

实例

python = {"张三", "李四", "王五"}
java = {"李四", "赵六"}
print(python & java)
以上实例输出结果为:
{'李四'}