Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #19516 > unrolled thread
| Started by | MRAB <python@mrabarnett.plus.com> |
|---|---|
| First post | 2012-01-27 02:53 +0000 |
| Last post | 2012-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.
Re: write 中文 into c:\t1 MRAB <python@mrabarnett.plus.com> - 2012-01-27 02:53 +0000
| From | MRAB <python@mrabarnett.plus.com> |
|---|---|
| Date | 2012-01-27 02:53 +0000 |
| Subject | Re: 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'))
Back to top | Article view | comp.lang.python
csiph-web