Today, when dealing with the interface returns data formatted error: TypeError: Object of type Response is not JSON serializable. The non-serializable object response
solve:
It prints out what type of response is the result, we found objects.
Then put the results into the response json, go to format the content of the response.
as follows:
Import Requests Import JSON URL = ' https://api.apishop.net/common/weather/get15DaysWeatherByArea ' apiKey = ' chgaxvsf88f3858a15fa4426f4cbdd4d2a02b92ee0747f3 ' Area = " Chongqing " areaID = " 101 040 100 " # quotation marks front TODO apikey, do not back up data = { " the apiKey " : apiKey, " Area " : Area, " areaID " : areaID, } DEFsend_post (URL, Data, areaID): Result = requests.post (URL, Data, areaID) ASSIGN = result.json () # TODO indent indented spaces pitch, sort_keys key according to sort, ensure_ascii decoded for display Chinese return json.dumps (ASSIGN, indent =. 4, sort_keys = True, ensure_ascii = False) # formatting returned content Print (send_post (URL, Data, areaID))