擅长:python、mysql、java
<p><a href="http://docs.python.org/library/csv.html#csv.writer" rel="noreferrer">The documentation</a>表明你想要的是不可能的:</p>
<blockquote>
<p>To make it as easy as possible to interface with modules which implement the DB API, the value None is written as the empty string.</p>
</blockquote>
<p>这在<code>writer</code>类的文档中,表明它适用于所有方言,并且是csv模块的内在限制。</p>
<p>我支持更改这个(以及csv模块的各种其他限制),但人们可能希望将这类工作卸载到不同的库中,并使csv模块保持简单(或至少尽可能简单)。</p>
<p>如果您需要更强大的文件读取功能,您可能需要查看numpy、scipy和pandas中的CSV读取功能,我记得它们有更多的选项。</p>