擅长:python、mysql、java
<p>我想你没有正确地复制名单。在</p>
<p>原始列表如下所示:</p>
<pre><code>[[1,2,3],[4,5,6],[7,8,9]]
</code></pre>
<p>复制时,将创建一个名为newA的新列表:</p>
^{pr2}$
<p>你只需添加元素:</p>
<pre><code>[1,2,3,4,5,6,7,8,9]
</code></pre>
<p>所以你的列表格式不同。在</p>
<p>这也许就是你想要的:</p>
<pre><code>newA=[]
row=[]
for row in range(0,height):
newRow = []
for col in range(0,width):
if A[row][col]==0:
newRow+=[0]
elif A[row][col]==1:
newRow+=[1]
newA += [newRow]
</code></pre>