0
How can I save a. json dictionary of a requests in txt. I tried to do it this way but it didn’t work.
import requests
import json
url = requests. get("https://search.ams.usda.gov/farmersmarkets/v1/data.svc/zipSearch?zip=46201")
response = json.loads(url.text)
arquivo = open("dados.txt", "w")
arquivo.write(response)
arquivo.close()
It creates the "data.txt" file but does not write the json dictionary data.
Wouldn’t it just be saving the content of the answer in the file? If the return is already in JSON format, just save it in the desired file, have no reason to convert to object and then save it.
– Woss