HTTPResponse object — JSON object must be str, not 'bytes'

后端 未结 4 1444
梦毁少年i
梦毁少年i 2020-12-02 20:51

I\'ve been trying to update a small Python library called libpynexmo to work with Python 3.

I\'ve been stuck on this function:

def send_request_json(         


        
4条回答
  •  借酒劲吻你
    2020-12-02 21:21

    Since you are getting a HTTPResponse, you can use Tornado.escape and its json_decode() to convert the JSON strign into a dictionary:

    from tornado import escape
    
    body = escape.json_decode(body)
    

    From the manual:

    tornado.escape.json_decode(value)

    Returns Python objects for the given JSON string.

提交回复
热议问题