Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.037 X-Spam-Evidence: '*H*': 0.93; '*S*': 0.00; 'skip:f 70': 0.09; 'subject:How': 0.10; 'skip:f 60': 0.16; 'url:ch': 0.16; 'win7': 0.16; 'skip:f 30': 0.19; '>>>': 0.22; 'import': 0.22; '>>>': 0.24; 'skip:p 30': 0.29; 'character': 0.29; 'message-id:@mail.gmail.com': 0.30; 'display': 0.35; 'received:google.com': 0.35; '8bit%:9': 0.36; 'skip:f 40': 0.36; 'subject:?': 0.36; 'skip:o 20': 0.38; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'skip:p 20': 0.39; 'how': 0.40; 'chinese': 0.74 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=mIaP9624kQSemqPODWqAqxOQl0aNnx4R0PP0rEzVWKI=; b=jomOTORLc2S+2dEtcjwj+fQsObWcBWZ4yR5jlFdBiHO3CGDi7L62fhy40z4O4nrs7x YSHuNdJtvR/pWwiWIGZJkrTuxOQSt9Q/+QKDipTjM7yEsg3unq6r8ISbYlcVN13FFvtW SH+kndRWgNGUWycf6rk2rcqKglxflSvC7VQQCG/p9D+W2qUmNkw9tgKDFtrT/XPWSt8/ ytN4qVrzjRHIbeLVCqKqNOoyY3FG9fh/T29z6ohXrHpRMZ4+y44cVZsx641Q5Hw+U+Y/ Rd5Rhh3EWhK/+HwOIPzb7+Djl9L4F5vuVSUz0JbtCzJ6aPjpSsYHWxjr6asRZc8XOi2p Dh7A== MIME-Version: 1.0 X-Received: by 10.112.22.130 with SMTP id d2mr9323882lbf.33.1397094877682; Wed, 09 Apr 2014 18:54:37 -0700 (PDT) Date: Thu, 10 Apr 2014 09:54:37 +0800 Subject: How to display chinese character in 65001 in pytohn? From: length power To: python-list@python.org Content-Type: multipart/alternative; boundary=14dae94732b9e6e1f304f6a67f52 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 38 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1397094885 news.xs4all.nl 2898 [2001:888:2000:d::a6]:36750 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:69997 --14dae94732b9e6e1f304f6a67f52 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable I am in win7 +python3.3. import os os.system("chcp 936") fh=3Dopen("test.ch","w",encoding=3D"utf-8") fh.write("=E4=BD=A0") fh.close() os.system("chcp 65001") fh=3Dopen("test.ch","r",encoding=3D"utf-8").read() print(fh) =C3=84=C3=A3 >>> print(fh.encode("utf-8")) b'\xe4\xbd\xa0' How can i display the chinese character `=E4=BD=A0` in 65001? --14dae94732b9e6e1f304f6a67f52 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
I am in win7 +python3.3.

=C2=A0=C2=A0=C2=A0 import= os
=C2=A0=C2=A0=C2=A0 os.system("chcp=C2=A0 936")
=C2=A0= =C2=A0=C2=A0 fh=3Dopen("test.ch",&= quot;w",encoding=3D"utf-8")
=C2=A0=C2=A0=C2=A0 fh.write(&= quot;=E4=BD=A0")
=C2=A0=C2=A0=C2=A0 fh.close()
=C2=A0=C2=A0=C2=A0 os.system("chcp 65= 001")
=C2=A0=C2=A0=C2=A0 fh=3Dopen("test.ch","r",encoding=3D"utf-8").read()
= =C2=A0=C2=A0=C2=A0 print(fh)
=C2=A0=C2=A0=C2=A0 =C3=84=C3=A3=C2=A0
= =C2=A0=C2=A0=C2=A0 >>> print(fh.encode("utf-8"))
=C2=A0=C2=A0=C2=A0 b'\xe4\xbd\xa0'

How can i display the chi= nese character=C2=A0 `=E4=BD=A0` in 65001?
--14dae94732b9e6e1f304f6a67f52--