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

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

      • <bdo id='ibXrA'></bdo><ul id='ibXrA'></ul>

      <tfoot id='ibXrA'></tfoot>
      1. <legend id='ibXrA'><style id='ibXrA'><dir id='ibXrA'><q id='ibXrA'></q></dir></style></legend>

      2. 如何将列表合并到元组列表中?

        How to merge lists into a list of tuples?(如何将列表合并到元组列表中?)

            <tfoot id='IiNLL'></tfoot>

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

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

              2. <legend id='IiNLL'><style id='IiNLL'><dir id='IiNLL'><q id='IiNLL'></q></dir></style></legend>
                  <tbody id='IiNLL'></tbody>

                • <bdo id='IiNLL'></bdo><ul id='IiNLL'></ul>
                  本文介绍了如何将列表合并到元组列表中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  实现以下目标的 Pythonic 方法是什么?

                  What is the Pythonic approach to achieve the following?

                  # Original lists:
                  
                  list_a = [1, 2, 3, 4]
                  list_b = [5, 6, 7, 8]
                  
                  # List of tuples from 'list_a' and 'list_b':
                  
                  list_c = [(1,5), (2,6), (3,7), (4,8)]
                  

                  list_c 的每个成员都是一个元组,其第一个成员来自 list_a,第二个成员来自 list_b.

                  Each member of list_c is a tuple, whose first member is from list_a and the second is from list_b.

                  推荐答案

                  在 Python 2 中:

                  In Python 2:

                  >>> list_a = [1, 2, 3, 4]
                  >>> list_b = [5, 6, 7, 8]
                  >>> zip(list_a, list_b)
                  [(1, 5), (2, 6), (3, 7), (4, 8)]
                  

                  在 Python 3 中:

                  In Python 3:

                  >>> list_a = [1, 2, 3, 4]
                  >>> list_b = [5, 6, 7, 8]
                  >>> list(zip(list_a, list_b))
                  [(1, 5), (2, 6), (3, 7), (4, 8)]
                  

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

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

                  相关文档推荐

                  groupby multiple coords along a single dimension in xarray(在xarray中按单个维度的多个坐标分组)
                  Group by and Sum in Pandas without losing columns(Pandas中的GROUP BY AND SUM不丢失列)
                  Group by + New Column + Grab value former row based on conditionals(GROUP BY+新列+基于条件的前一行抓取值)
                  Groupby and interpolate in Pandas(PANDA中的Groupby算法和插值算法)
                  Pandas - Group Rows based on a column and replace NaN with non-null values(PANAS-基于列对行进行分组,并将NaN替换为非空值)
                  Grouping pandas DataFrame by 10 minute intervals(按10分钟间隔对 pandas 数据帧进行分组)
                  • <bdo id='cT9VX'></bdo><ul id='cT9VX'></ul>

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

                          <tbody id='cT9VX'></tbody>

                        • <small id='cT9VX'></small><noframes id='cT9VX'>

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