334862132
V2EX  ›  问与答

python3.6 里 django 编码解码问题

  •  
  •   334862132 · Nov 15, 2018 · 1618 views
    This topic created in 2823 days ago, the information mentioned may be changed or developed.

    django 里面用 request.POST 接收到的文件,用 json.dumps 做了处理打印出来了,对面号称用 utf8 解码一下就可以,但是\u6d5c 之类的一堆乱码根本解不开啊,ret3 的数据可以用 encode(gbk)之后用 decode(utf-8)可以解出来 但是到 ret1 就解不出来了 用 ignore 忽略错误后可以解出来 但是解出来后数据就不完整了,求各位大神给个解决办法

    json.dumps 处理后的原生字符串: {"rt2_retCode": "0000", "rt4_notifyType": "ORDER_STATUS", "rt1_reason": "\u6d5c\u3086\u69d7\u93b4\u612c\u59db\u951b\u5c7d\u5f2c\u9354\u72b3\u7afb\u7ee0\ufffd", "rt3_retMsg": "\u6d5c\u3086\u69d7\u93b4\u612c\u59db\u9359\u6943\u608a", "UTF-8": ""}

    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1312 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 22ms · UTC 17:14 · PVG 01:14 · LAX 10:14 · JFK 13:14
    ♥ Do have faith in what you're doing.