擅长:python、mysql、java
<p>事实上,你得到了一个“指针”。列表(以及任何可变值类型!)在Python中作为引用传递。你知道吗</p>
<p>您可以将列表的副本传递给<code>list()</code>对象构造函数,或者使用<code>[:]</code>生成完整的片。你知道吗</p>
<pre><code>a = [1,2,3]
b = a
c = list(a)
d = a[:]
a[1] = 4 # changes the list referenced by both 'a' and 'b', but not 'c' or 'd'
</code></pre>