<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)]
                  

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

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

                  相关文档推荐

                  Initialize Multiple Numpy Arrays (Multiple Assignment) - Like MATLAB deal()(初始化多个 Numpy 数组(多重赋值) - 像 MATLAB deal())
                  How to extend Python class init(如何扩展 Python 类初始化)
                  What#39;s the difference between dict() and {}?(dict() 和 {} 有什么区别?)
                  What is a wrapper_descriptor, and why is Foo.__init__() one in this case?(什么是 wrapper_descriptor,为什么 Foo.__init__() 在这种情况下是其中之一?)
                  Initialize list with same bool value(使用相同的布尔值初始化列表)
                  setattr with kwargs, pythonic or not?(setattr 与 kwargs,pythonic 与否?)
                  • <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>