擅长:python、mysql、java
<p>在windows上使用python时会出现以下问题:</p>
<p>如果使用的是Python 3.x,请在打开要写入的文件时添加此参数:</p>
<pre><code>newline=''
</code></pre>
<p>示例:</p>
<pre><code>with open('test_csv.csv','w',newline='') as file:
</code></pre>
<p>如果您使用的是python2,请使用<code>"wb"</code>而不是<code>"w"</code>打开文件。你知道吗</p>
<pre><code>with open('test_csv.csv','wb') as file:
</code></pre>
<p>引用:<a href="https://stackoverflow.com/questions/30929363/csv-writerows-puts-newline-after-each-row">here</a></p>
<p>希望这有帮助。你知道吗</p>