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


Groups > comp.lang.python > #69997

How to display chinese character in 65001 in pytohn?

Date 2014-04-10 09:54 +0800
Subject How to display chinese character in 65001 in pytohn?
From length power <elearn2014@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.9104.1397094885.18130.python-list@python.org> (permalink)

Show all headers | View raw


[Multipart message — attachments visible in raw view] - view raw

I am in win7 +python3.3.

    import os
    os.system("chcp  936")
    fh=open("test.ch","w",encoding="utf-8")
    fh.write("你")
    fh.close()
    os.system("chcp 65001")
    fh=open("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?

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

How to display chinese character in 65001 in pytohn? length power <elearn2014@gmail.com> - 2014-04-10 09:54 +0800

csiph-web