intersection Python · 集合方法
返回两个集合共有元素组成的新集合。
怎么用
集合.intersection(另一个集合)
小例子
print({1, 2}.intersection({2, 3}))
运行结果
{2}
官方文档:https://docs.python.org/zh-cn/3/library/stdtypes.html#set
在代码里遇到不认识的词?打开代码点读机,点一下就懂 → ← Python全部词条