Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #19516
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <python@mrabarnett.plus.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.008 |
| X-Spam-Evidence | '*H*': 0.98; '*S*': 0.00; '>>>>': 0.09; 'from:addr:python': 0.09; 'syntax': 0.15; 'file.close()': 0.16; 'from:addr:mrabarnett.plus.com': 0.16; 'from:name:mrab': 0.16; 'message-id:@mrabarnett.plus.com': 0.16; 'received:84.92': 0.16; 'received:84.92.122': 0.16; 'received:84.92.122.60': 0.16; 'received:84.93': 0.16; 'received:84.93.230': 0.16; 'reply-to:addr :python-list': 0.16; 'syntaxerror:': 0.16; 'wrote:': 0.16; '>>>': 0.18; 'header:In-Reply-To:1': 0.22; 'invalid': 0.28; 'print': 0.29; 'header:User-Agent:1': 0.33; 'to:addr:python-list': 0.33; 'received:84': 0.34; 'reply-to:addr:python.org': 0.34; 'file': 0.35; 'open': 0.38; 'subject:: ': 0.39; 'to:addr:python.org': 0.40; 'header:Reply-To:1': 0.71; 'reply-to:no real name:2**0': 0.72; 'subjectcharset:utf-8': 0.73; 'subject:write': 0.84 |
| X-CM-Score | 0.00 |
| X-CNFS-Analysis | v=2.0 cv=borO9Tmi c=1 sm=1 a=0nF1XD0wxitMEM03M9B4ZQ==:17 a=FFsdPcU1_MIA:10 a=koNe95EJPpEA:10 a=jPJDawAOAc8A:10 a=OUOv7kDek9cA:10 a=IkcTkHD0fZMA:10 a=uI9eOeOZVC6-wwBZzfkA:9 a=QEXdDO2ut3YA:10 a=0nF1XD0wxitMEM03M9B4ZQ==:117 |
| X-AUTH | mrabarnett:2500 |
| Date | Fri, 27 Jan 2012 02:53:18 +0000 |
| From | MRAB <python@mrabarnett.plus.com> |
| User-Agent | Mozilla/5.0 (Windows NT 5.1; rv:9.0) Gecko/20111222 Thunderbird/9.0.1 |
| MIME-Version | 1.0 |
| To | python-list@python.org |
| Subject | Re: write 中文 into c:\t1 |
| References | <CA+YdQ_4SdtzD_vk4uUG37mOTHKi0r+_aJJXy89wvsJFbr1x2_Q@mail.gmail.com> |
| In-Reply-To | <CA+YdQ_4SdtzD_vk4uUG37mOTHKi0r+_aJJXy89wvsJFbr1x2_Q@mail.gmail.com> |
| Content-Type | text/plain; charset=UTF-8; format=flowed |
| Content-Transfer-Encoding | 8bit |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.12 |
| Precedence | list |
| Reply-To | python-list@python.org |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.5149.1327632778.27778.python-list@python.org> (permalink) |
| Lines | 28 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1327632778 news.xs4all.nl 6887 [2001:888:2000:d::a6]:53787 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.python:19516 |
Show key headers only | View raw
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