<bdo id='RSiTO'></bdo><ul id='RSiTO'></ul>

    <legend id='RSiTO'><style id='RSiTO'><dir id='RSiTO'><q id='RSiTO'></q></dir></style></legend>
    <i id='RSiTO'><tr id='RSiTO'><dt id='RSiTO'><q id='RSiTO'><span id='RSiTO'><b id='RSiTO'><form id='RSiTO'><ins id='RSiTO'></ins><ul id='RSiTO'></ul><sub id='RSiTO'></sub></form><legend id='RSiTO'></legend><bdo id='RSiTO'><pre id='RSiTO'><center id='RSiTO'></center></pre></bdo></b><th id='RSiTO'></th></span></q></dt></tr></i><div id='RSiTO'><tfoot id='RSiTO'></tfoot><dl id='RSiTO'><fieldset id='RSiTO'></fieldset></dl></div>
    1. <tfoot id='RSiTO'></tfoot>

      <small id='RSiTO'></small><noframes id='RSiTO'>

      1. 如何在 Python 的集合列表中找到并集?

        How can I find the union on a list of sets in Python?(如何在 Python 的集合列表中找到并集?)

        <legend id='nLYpo'><style id='nLYpo'><dir id='nLYpo'><q id='nLYpo'></q></dir></style></legend>

          <tbody id='nLYpo'></tbody>
          • <bdo id='nLYpo'></bdo><ul id='nLYpo'></ul>

              <small id='nLYpo'></small><noframes id='nLYpo'>

                1. <i id='nLYpo'><tr id='nLYpo'><dt id='nLYpo'><q id='nLYpo'><span id='nLYpo'><b id='nLYpo'><form id='nLYpo'><ins id='nLYpo'></ins><ul id='nLYpo'></ul><sub id='nLYpo'></sub></form><legend id='nLYpo'></legend><bdo id='nLYpo'><pre id='nLYpo'><center id='nLYpo'></center></pre></bdo></b><th id='nLYpo'></th></span></q></dt></tr></i><div id='nLYpo'><tfoot id='nLYpo'></tfoot><dl id='nLYpo'><fieldset id='nLYpo'></fieldset></dl></div>
                  <tfoot id='nLYpo'></tfoot>

                  本文介绍了如何在 Python 的集合列表中找到并集?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  这是输入:

                  x = [{1, 2, 3}, {2, 3, 4}, {3, 4, 5}]
                  

                  输出应该是:

                  {1, 2, 3, 4, 5}
                  

                  我尝试使用 set().union(x) 但这是我得到的错误:

                  I tried to use set().union(x) but this is the error I'm getting:

                  Traceback (most recent call last):
                    File "<stdin>", line 1, in <module>
                  TypeError: unhashable type: 'set'
                  

                  推荐答案

                  set.unionunion(other, ...).从您的列表中解压套装:

                  The signature of set.union is union(other, ...). Unpack sets from your list:

                  In [6]: set.union(*x)
                  Out[6]: {1, 2, 3, 4, 5}
                  

                  这篇关于如何在 Python 的集合列表中找到并集?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Pythonic and efficient way of finding adjacent cells in grid(在网格中查找相邻单元格的 Pythonic 和有效方法)
                  map a hexagonal grid in matplotlib(在 matplotlib 中映射六边形网格)
                  Execute arbitrary python code remotely - can it be done?(远程执行任意 python 代码 - 可以吗?)
                  Python - Plotting colored grid based on values(Python - 根据值绘制彩色网格)
                  Is there a GUI design app for the Tkinter / grid geometry?(是否有 Tkinter/网格几何图形的 GUI 设计应用程序?)
                  tkinter Canvas Scrollbar with Grid?(带有网格的 tkinter 画布滚动条?)
                    <tbody id='k5ko4'></tbody>
                  <legend id='k5ko4'><style id='k5ko4'><dir id='k5ko4'><q id='k5ko4'></q></dir></style></legend>
                2. <i id='k5ko4'><tr id='k5ko4'><dt id='k5ko4'><q id='k5ko4'><span id='k5ko4'><b id='k5ko4'><form id='k5ko4'><ins id='k5ko4'></ins><ul id='k5ko4'></ul><sub id='k5ko4'></sub></form><legend id='k5ko4'></legend><bdo id='k5ko4'><pre id='k5ko4'><center id='k5ko4'></center></pre></bdo></b><th id='k5ko4'></th></span></q></dt></tr></i><div id='k5ko4'><tfoot id='k5ko4'></tfoot><dl id='k5ko4'><fieldset id='k5ko4'></fieldset></dl></div>
                        <bdo id='k5ko4'></bdo><ul id='k5ko4'></ul>

                        <small id='k5ko4'></small><noframes id='k5ko4'>

                        <tfoot id='k5ko4'></tfoot>