• <tfoot id='OFnjb'></tfoot>

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

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

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

        将列表元素附加到python中的列表列表

        时间:2023-09-27
        <i id='VcG8G'><tr id='VcG8G'><dt id='VcG8G'><q id='VcG8G'><span id='VcG8G'><b id='VcG8G'><form id='VcG8G'><ins id='VcG8G'></ins><ul id='VcG8G'></ul><sub id='VcG8G'></sub></form><legend id='VcG8G'></legend><bdo id='VcG8G'><pre id='VcG8G'><center id='VcG8G'></center></pre></bdo></b><th id='VcG8G'></th></span></q></dt></tr></i><div id='VcG8G'><tfoot id='VcG8G'></tfoot><dl id='VcG8G'><fieldset id='VcG8G'></fieldset></dl></div>
        • <bdo id='VcG8G'></bdo><ul id='VcG8G'></ul>
        • <tfoot id='VcG8G'></tfoot>
          1. <small id='VcG8G'></small><noframes id='VcG8G'>

              <tbody id='VcG8G'></tbody>

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

                  本文介绍了将列表元素附加到python中的列表列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  鉴于以下列表:

                  list1 = [[1, 2],
                           [3, 4],
                           [5, 6],
                           [7, 8]]
                  list2 = [10, 11, 12, 13]
                  

                  更改 list1 使其成为 python 中的以下列表的最佳方法是什么?

                  What is the best way to change list1 so it becomes the following list in python?

                  [[1, 2, 10],
                   [3, 4, 11],
                   [5, 6, 12],
                   [7, 8, 13]]
                  

                  推荐答案

                  可以使用zip:

                  [x + [y] for x, y in zip(list1, list2)]
                  # [[1, 2, 10], [3, 4, 11], [5, 6, 12], [7, 8, 13]]
                  

                  要修改 list1,你可以这样做:

                  To modify list1 in place, you could do:

                  for x, y in zip(list1, list2):
                      x.append(y)
                  
                  list1
                  # [[1, 2, 10], [3, 4, 11], [5, 6, 12], [7, 8, 13]]
                  

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

                  上一篇:附加到覆盖先前值的元组 下一篇:如何将值附加到 dict 键?(AttributeError:'str'对象没有属性'appen

                  相关文章

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

                    1. <tfoot id='wq2fa'></tfoot>
                        <bdo id='wq2fa'></bdo><ul id='wq2fa'></ul>

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