YUCOAT
V2EX  ›  问与答

Python3 调用 encode 转码之后,怎么再转回去。

  •  
  •   YUCOAT · Aug 6, 2014 · 4945 views
    This topic created in 4323 days ago, the information mentioned may be changed or developed.
    以前我用Python2的时候,可以用decode/encode将字符从各种编码之间进行转换

    现在换Python3了,当我调用
    '中文'.encode('gb2312')
    可以转换成
    b'\xd6\xd0\xce\xc4'之后
    怎么再把b'\xd6\xd0\xce\xc4'转换成'中文'呢?
    2 replies    2014-08-06 17:00:51 +08:00
    hahastudio
        1
    hahastudio  
       Aug 6, 2014   ❤️ 1
    b'\xd6\xd0\xce\xc4'.decode("gb2312")
    YUCOAT
        2
    YUCOAT  
    OP
       Aug 6, 2014
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5825 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 30ms · UTC 01:48 · PVG 09:48 · LAX 18:48 · JFK 21:48
    ♥ Do have faith in what you're doing.