回复: write 中文 into c:\t1
水静流深
1248283536 at qq.com
Thu Jan 26 22:00:09 EST 2012
file.write(s.decode('gbk').encode('utf-8'))
i open the file c:\t1, to get 中文 in it
not 涓枃
------------------ 原始邮件 ------------------
发件人: "MRAB"<python at mrabarnett.plus.com>;
发送时间: 2012年1月27日(星期五) 上午10:53
收件人: "python-list"<python-list at python.org>;
主题: Re: write 中文 into c:\t1
On 27/01/2012 02:46, contro opinion wrote:
> |>>> s='\xd6\xd0\xce\xc4'
>
>>>> print s
>>>> 中文
>
>>>> s1=s.decode('gbk').encode('utf-8')
>
>>>> print s1
>>>> 涓枃
>
>>>> file=open('c:\\t1','w')
>
>>>> file.write(s1)
>
>>>> file.close()
> |
>
> when i open c:\t1,i get 中文 in it,
> how can i write 涓枃 into c:\t1??
>
> >>> file.write(print s1)
> File "<stdin>", line 1
> file.write(print s1)
> ^
> SyntaxError: invalid syntax
>
file.write(s.decode('gbk').encode('utf-8'))
--
http://mail.python.org/mailman/listinfo/python-list
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20120127/9e9491a0/attachment.html>
More information about the Python-list
mailing list