【问题标题】:Intersection operation on set [duplicate]集合上的交集操作[重复]
【发布时间】:2016-11-03 15:24:07
【问题描述】:

我在后面的列表中有两组,

set_list= [{224, 3, 138, 17, 222, 223}, {226, 3, 46, 17, 222, 223}]

我想在这个列表上应用交集运算,输出应该是这样的:

set_list= [3,17,222,223]

【问题讨论】:

  • 使用set.intersection(*set_list)。仅供参考,我必须在谷歌上搜索“python 中多个集合的交集”才能找到重复项。
  • 非常感谢它的工作。 :D

标签: python list set intersection


【解决方案1】:
result  = set.intersection(*set_list)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-04-17
    • 2012-12-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-09-11
    • 2014-07-19
    • 2014-08-26
    相关资源
    最近更新 更多