Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #70004
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.albasani.net!news.roellig-ltd.de!open-news-network.org!cyclone03.ams2.highwinds-media.com!news.highwinds-media.com!voer-me.highwinds-media.com!eweka.nl!lightspeed.eweka.nl!194.109.133.83.MISMATCH!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <elearn2014@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.000 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'python.': 0.02; 'win32': 0.03; 'broken': 0.04; 'mrab': 0.05; 'output': 0.05; 'binary': 0.07; 'see:': 0.07; 'bytes.': 0.09; 'happen.': 0.09; 'url:github': 0.09; 'variable,': 0.09; 'subject:How': 0.10; 'cc:addr:python- list': 0.11; 'python': 0.11; 'cmd': 0.16; 'codecs': 0.16; 'skip:< 20': 0.16; 'skip:n 110': 0.16; 'skip:n 50': 0.16; 'sys.stdout': 0.16; 'url:ch': 0.16; 'win7': 0.16; 'fix': 0.17; 'wrote:': 0.18; 'written': 0.21; '>>>': 0.22; 'input': 0.22; 'import': 0.22; 'cc:addr:python.org': 0.22; 'specify': 0.24; 'tells': 0.24; 'environment': 0.24; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; 'this:': 0.26; 'post': 0.26; 'header:In-Reply-To:1': 0.27; 'tried': 0.27; 'skip:p 30': 0.29; 'character': 0.29; 'generally': 0.29; 'characters': 0.30; 'mode': 0.30; 'skip:& 60': 0.30; 'skip:g 30': 0.30; 'message-id:@mail.gmail.com': 0.30; 'url:mailman': 0.30; '8bit%:2': 0.31; 'url:python': 0.33; 'maybe': 0.34; 'problem': 0.35; "can't": 0.35; 'display': 0.35; 'but': 0.35; 'received:google.com': 0.35; '8bit%:9': 0.36; 'url:listinfo': 0.36; 'subject:?': 0.36; 'url:org': 0.36; 'operating': 0.37; 'skip:p 20': 0.39; 'url:mail': 0.40; 'how': 0.40; 'skip:\xc2 10': 0.60; 'tell': 0.60; 'length': 0.61; 'answer.': 0.68; 'chinese': 0.74; 'power': 0.76 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=sHLBE/Fv+4iRClsnrN/y2JIpnfxHTA4GVwnE8S9YxGY=; b=kcuf4NTcGkqcAFybkDwTplSic+w9Wm6Tv0UBro7WobHEMBGVsxmkmOFKWHuMxYyKSO WcE1pVNsLJKNM5SjyTuma23UqFeO3Vcbyt5wWFdQohjlCXLU0H0IoCl4wYfQ/cpn+oAA ll8w8VWzanKYHLlaSerWRHyQg4fVCmK8CMIh04ME7sggbwi6zsGC2sw6Rpgpv1Uf2u3L HpgixbaAT2IvY0AI9uAHdWcKnxfBDkEZQR9tjDxZwasRENi/hQ3aEIH8mZ65rqg8QiQ/ DAq0abh3L8l26jDt+G+c45OJYmT63FznbxyFRuHgMJ55XFJYx79XYdVUNHO0KUKArY9l 2tkA== |
| MIME-Version | 1.0 |
| X-Received | by 10.152.36.73 with SMTP id o9mr10256490laj.30.1397099967472; Wed, 09 Apr 2014 20:19:27 -0700 (PDT) |
| In-Reply-To | <CAOmh461hHwFikg9QBNtkd3GPqoU0pmBpjEd2qx=2x-bdv0CtjQ@mail.gmail.com> |
| References | <CAOmh4638E4WggAMobFn2qkPbDCgEBkdn5eVub9pjNy2icVuOyA@mail.gmail.com> <534601A1.5040005@mrabarnett.plus.com> <CAOmh461hHwFikg9QBNtkd3GPqoU0pmBpjEd2qx=2x-bdv0CtjQ@mail.gmail.com> |
| Date | Thu, 10 Apr 2014 11:19:27 +0800 |
| Subject | Re: How to display chinese character in 65001 in pytohn? |
| From | length power <elearn2014@gmail.com> |
| To | MRAB <python@mrabarnett.plus.com> |
| Content-Type | multipart/alternative; boundary=089e0160adf846e99304f6a7af02 |
| Cc | python-list@python.org |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://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 | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.9109.1397099969.18130.python-list@python.org> (permalink) |
| Lines | 201 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1397099969 news.xs4all.nl 2901 [2001:888:2000:d::a6]:46204 |
| X-Complaints-To | abuse@xs4all.nl |
| X-Received-Bytes | 14677 |
| X-Received-Body-CRC | 1980956839 |
| Xref | csiph.com comp.lang.python:70004 |
Show key headers only | View raw
[Multipart message — attachments visible in raw view] - view raw
problem solved.if you enter python by python(command line),the problem
can't be solved.if you enter python by cmd ,and input python,no problem
happen.
2014-04-10 11:05 GMT+08:00 length power <elearn2014@gmail.com>:
> i tried this way ,and post it in stackoverflow,please see:
> maybe it is the best answer.
> Codepage 65001 is generally broken in binary mode as used by Python 3,
> since _write calls Win32 WriteFile, which calls WriteConsoleA, which
> returns the number of characters written instead of the number of bytes.
> That confuses Python. ANSICON <https://github.com/adoxa/ansicon> can hook
> WriteFile to fix this for programs that you specify in an environment
> variable, but that won't help with input.
>
>
> http://stackoverflow.com/questions/22977409/how-to-display-chinese-character-in-65001-in-pytohn?noredirect=1#comment35087732_22977409
>
>
> 2014-04-10 10:27 GMT+08:00 MRAB <python@mrabarnett.plus.com>:
>
> On 2014-04-10 02:54, length power wrote:
>>
>>> I am in win7 +python3.3.
>>>
>>> import os
>>> os.system("chcp 936")
>>> fh=open("test.ch <http://test.ch>","w",encoding="utf-8")
>>>
>>> fh.write("你")
>>> fh.close()
>>> os.system("chcp 65001")
>>> fh=open("test.ch <http://test.ch>","r",encoding="utf-8").read()
>>>
>>> print(fh)
>>> Äã
>>> >>> print(fh.encode("utf-8"))
>>> b'\xe4\xbd\xa0'
>>>
>>> How can i display the chinese character `你` in 65001?
>>>
>>> The "chcp 65001" tells the operating system to use UTF-8, but you also
>> have to tell Python to output UTF-8. Try this:
>>
>> from codecs import getwriter
>> sys.stdout = getwriter('utf-8')(sys.stdout.detach())
>>
>> --
>> https://mail.python.org/mailman/listinfo/python-list
>>
>
>
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: How to display chinese character in 65001 in pytohn? length power <elearn2014@gmail.com> - 2014-04-10 11:19 +0800
csiph-web