<p>请参见<a href="https://docs.python.org/2/library/stdtypes.html#sequence-types-str-unicode-list-tuple-bytearray-buffer-xrange" rel="noreferrer">Python standard types page</a>:</p>
<pre><code>>>> [''] * 16
['', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '']
</code></pre>
<blockquote>
<p>s * n, n * s</p>
<p>n shallow copies of s concatenated</p>
</blockquote>
<p>其中,<code>s</code>是一个序列,<code>n</code>是一个整数。</p>
<p>此操作文档的完整脚注:</p>
<blockquote>
<p>Values of n less than 0 are treated as 0 (which yields an empty sequence of the same type as s). Note also that the copies are shallow; nested structures are not copied. This often haunts new Python programmers; consider:</p>
</blockquote>
<pre><code>>>> lists = [[]] * 3
>>> lists
[[], [], []]
>>> lists[0].append(3)
>>> lists
[[3], [3], [3]]
</code></pre>
<blockquote>
<p>What has happened is that [[]] is a one-element list containing an empty list, so all three elements of [[]] * 3 are (pointers to) this single empty list. Modifying any of the elements of lists modifies this single list. You can create a list of different lists this way:</p>
</blockquote>
<pre><code>>>> lists = [[] for i in range(3)]
>>> lists[0].append(3)
>>> lists[1].append(5)
>>> lists[2].append(7)
>>> lists
[[3], [5], [7]]
</code></pre>