Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #19516 > unrolled thread

Re: write 中文 into c:\t1

Started byMRAB <python@mrabarnett.plus.com>
First post2012-01-27 02:53 +0000
Last post2012-01-27 02:53 +0000
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: write 中文 into c:\t1 MRAB <python@mrabarnett.plus.com> - 2012-01-27 02:53 +0000

#19516 — Re: write 中文 into c:\t1

FromMRAB <python@mrabarnett.plus.com>
Date2012-01-27 02:53 +0000
SubjectRe: write 中文 into c:\t1
Message-ID<mailman.5149.1327632778.27778.python-list@python.org>
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'))

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web