擅长:python、mysql、java
<p>我做过这样的事情,而且很有效:</p>
<pre class="lang-py prettyprint-override"><code>>>> s = u'Feb 21 10:10 W\x00i\x00l\x00l\x00 a\x00r\x00r\x00i\x00v\x00e \x00c\x00o\x00n\x00t\x00ro\x00l\x00 \x00X\x00X\x00 m\x00i\x00n'
>>> f = open('test.txt', 'wb')
>>> f.write(s.encode())
>>> exit()
$ cat test.txt
Feb 21 10:10 Will arrive control XX min
</code></pre>
<p>但是当我没有二进制的时候</p>
<pre class="lang-py prettyprint-override"><code>>>> s = u'Feb 21 10:10 W\x00i\x00l\x00l\x00 a\x00r\x00r\x00i\x00v\x00e \x00c\x00o\x00n\x00t\x00ro\x00l\x00 \x00X\x00X\x00 m\x00i\x00n'
>>> f = open('test.txt', 'w')
>>> f.write(s)
$ cat test.txt
Feb 21 10:10 Will arrive control XX min
</code></pre>
<p>一切看起来都很好,所以我不知道你做错了什么。也许你的文本浏览器有问题?你知道吗</p>