擅长:python、mysql、java
<p>根据@G M的回答,并注意@John La Rooy的警告,我可以在<code>'a'</code>模式下添加一个新行来打开文件。</p>
<blockquote>
<p>Even in windows, in order to avoid the newline problem, you must declare it as <code>newline=''</code>.</p>
<p>Now you can open the file in <code>'a'</code>mode (without the b).</p>
</blockquote>
<pre><code>import csv
with open(r'names.csv', 'a', newline='') as csvfile:
fieldnames = ['This','aNew']
writer = csv.DictWriter(csvfile, fieldnames=fieldnames)
writer.writerow({'This':'is', 'aNew':'Row'})
</code></pre>
<p>我没有试着和普通作家(没有口述稿)一起写,但我想也可以。</p>