擅长:python、mysql、java
<p>您的数据是<em>unicode</em>数据。要将其写入文件,请使用<code>.encode()</code>:</p>
<pre><code>text = text.encode('ascii', 'ignore')
</code></pre>
<p>但这将删除任何不是ASCII的内容。也许你想编码成更合适的编码,比如UTF-8?</p>
<p>您可能需要阅读Python和Unicode:</p>
<ul>
<li><p><a href="http://joelonsoftware.com/articles/Unicode.html">The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets (No Excuses!)</a>作者Joel Spolsky</p></li>
<li><p><a href="http://docs.python.org/2/howto/unicode.html">Python Unicode HOWTO</a></p></li>
<li><p><a href="http://nedbatchelder.com/text/unipain.html">Pragmatic Unicode</a>作者:Ned Batchelder</p></li>
</ul>