<tfoot id='SmDyg'></tfoot>

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

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

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

      1. python中用于列表操作的plus和append有什么区别?

        What#39;s the difference between plus and append in python for list manipulation?(python中用于列表操作的plus和append有什么区别?)
          <i id='EjMzu'><tr id='EjMzu'><dt id='EjMzu'><q id='EjMzu'><span id='EjMzu'><b id='EjMzu'><form id='EjMzu'><ins id='EjMzu'></ins><ul id='EjMzu'></ul><sub id='EjMzu'></sub></form><legend id='EjMzu'></legend><bdo id='EjMzu'><pre id='EjMzu'><center id='EjMzu'></center></pre></bdo></b><th id='EjMzu'></th></span></q></dt></tr></i><div id='EjMzu'><tfoot id='EjMzu'></tfoot><dl id='EjMzu'><fieldset id='EjMzu'></fieldset></dl></div>
          <tfoot id='EjMzu'></tfoot>

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

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

            <tbody id='EjMzu'></tbody>

                  <bdo id='EjMzu'></bdo><ul id='EjMzu'></ul>
                  本文介绍了python中用于列表操作的plus和append有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  可能重复:
                  Python append() vs. + 运算符在列表中,为什么这些会给出不同的结果?

                  在 Python 中用于列表操作的+"和附加"之间的实际区别是什么?

                  What is the actual difference between "+" and "append" for list manipulation in Python?

                  推荐答案

                  有两个主要区别.首先是 + 在含义上更接近于 extend 而不是 append:

                  There are two major differences. The first is that + is closer in meaning to extend than to append:

                  >>> a = [1, 2, 3]
                  >>> a + 4
                  Traceback (most recent call last):
                    File "<pyshell#13>", line 1, in <module>
                      a + 4
                  TypeError: can only concatenate list (not "int") to list
                  >>> a + [4]
                  [1, 2, 3, 4]
                  >>> a.append([4])
                  >>> a
                  [1, 2, 3, [4]]
                  >>> a.extend([4])
                  >>> a
                  [1, 2, 3, [4], 4]
                  

                  另一个更突出的区别是方法就地工作:extend 实际上类似于 += - 事实上,它的行为与+= 除了它可以接受任何可迭代的,而 += 只能接受另一个列表.

                  The other, more prominent, difference is that the methods work in-place: extend is actually like += - in fact, it has exactly the same behavior as += except that it can accept any iterable, while += can only take another list.

                  这篇关于python中用于列表操作的plus和append有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  Adding config modes to Plotly.Py offline - modebar(将配置模式添加到 Plotly.Py 离线 - 模式栏)
                  Plotly: How to style a plotly figure so that it doesn#39;t display gaps for missing dates?(Plotly:如何设置绘图图形的样式,使其不显示缺失日期的间隙?)
                  python save plotly plot to local file and insert into html(python将绘图保存到本地文件并插入到html中)
                  Plotly: What color cycle does plotly express follow?(情节:情节表达遵循什么颜色循环?)
                  How to save plotly express plot into a html or static image file?(如何将情节表达图保存到 html 或静态图像文件中?)
                  Plotly: How to make a line plot from a pandas dataframe with a long or wide format?(Plotly:如何使用长格式或宽格式的 pandas 数据框制作线图?)

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

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

                  <tfoot id='xwtRM'></tfoot>

                      <tbody id='xwtRM'></tbody>
                    • <legend id='xwtRM'><style id='xwtRM'><dir id='xwtRM'><q id='xwtRM'></q></dir></style></legend>
                          • <bdo id='xwtRM'></bdo><ul id='xwtRM'></ul>