• <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中的列表列表

        Append list elements to list of lists in python(将列表元素附加到python中的列表列表)
        <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中的列表列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  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 数据帧进行分组)
                  <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>

                    <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>
                              <tbody id='wq2fa'></tbody>