Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #19516
| Date | 2012-01-27 02:53 +0000 |
|---|---|
| From | MRAB <python@mrabarnett.plus.com> |
| Subject | Re: write 中文 into c:\t1 |
| References | <CA+YdQ_4SdtzD_vk4uUG37mOTHKi0r+_aJJXy89wvsJFbr1x2_Q@mail.gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.5149.1327632778.27778.python-list@python.org> (permalink) |
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'))
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: write 中文 into c:\t1 MRAB <python@mrabarnett.plus.com> - 2012-01-27 02:53 +0000
csiph-web