Home >Backend Development >Python Tutorial >在Python中,令values=[0,1,2];values[1]=values,为何结果是[0,[...],2]?

在Python中,令values=[0,1,2];values[1]=values,为何结果是[0,[...],2]?

WBOY
WBOYOriginal
2016-06-06 16:03:542091browse

<span class="o">>>></span> <span class="n">values</span> <span class="o">=</span> <span class="p">[</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">]</span>
<span class="o">>>></span> <span class="n">values</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">=</span> <span class="n">values</span>
<span class="o">>>></span> <span class="n">values</span>
<span class="p">[</span><span class="mi">0</span><span class="p">,</span> <span class="p">[</span><span class="o">...</span><span class="p">],</span> <span class="mi">2</span><span class="p">]</span>
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn