TypeError: the JSON object must be str, not 'bytes'

前端 未结 3 1667
不知归路
不知归路 2020-11-29 02:55

I have the following, very basic code that throws; TypeError: the JSON object must be str, not \'bytes\'

import requests
import json

url = \'my         


        
3条回答
  •  半阙折子戏
    2020-11-29 03:05

    Let requests decode it for you:

    data = response.json()
    

    This will check headers (Content-Type) and response encoding, auto-detecting how to decode the content correctly.

提交回复
热议问题