<p>发生这种情况的原因是因为<code>scris</code>是一个列表。在</p>
<p>而不是:</p>
<pre><code>row_test.append(scris[0:7])
</code></pre>
<p>不如这样做:</p>
^{pr2}$
<p>这也很管用(见下面的评论):</p>
<pre><code>row_test.extend(scris[0:7])
</code></pre>
<p>如果仍然没有意义,打开一个控制台并输入下面的示例。每次更改<code>l</code>请将其打印出来。在</p>
<p>下面的示例应该向您展示为什么这样做:</p>
<pre><code>l = [1,2,3] # l = [1,2,3]
l.extend([4,5]) #now l = [1,2,3,4,5]
l.append([6,7]) #now l = [1,2,3,4,5,[6,7]]
l.extend('hi there') #raises an exception
</code></pre>
<p>当您调用<code>some_list.append(some_item)</code>时,它将<code>some_item</code><em>放入</em><code>some_list</code>。所以如果<code>some_item</code>也是一个列表,那么在列表中就有一个列表。在</p>
<p>当您调用<code>some_list.extend(some_item)</code>时,它将<em>连接到<code>some_list</code>的结尾。所以如果<code>some_item</code>不是一个列表,那么这将出错。在</p>
<p><strong>编辑</strong>我想我现在明白你想要什么了。。。在</p>
<p>所以给定一个类似<code>[['1','2','3'],['4','5','6'],['7','8','9']]</code>的列表,你希望csv看起来像:<code>123,456,789</code>,对吗?在</p>
<p>而不是:</p>
<pre><code>fisier_text_knife.writerow(row_test)
</code></pre>
<p>试试这个:</p>
<pre><code>csv_friendly = [''.join(l) for l in row_test]
fisier_text_knife.writerow(csv_friendly)
</code></pre>