如何在Python中保存对文件的响应?

如何在Python中保存对文件的响应?,python,save,write,Python,Save,Write,附加图像是AWS Rekognition的简单目标检测结果。 我想知道是否有人可以帮助我将响应保存到文件(CSV、文本或JSON)中 JSON文件: with open('response.txt', 'w') as outfile: json.dump(response, outfile) 您可以使用pathlib模块中的Path类写入json文件 with open('response.txt', 'w') as outfile: json.dump(response, o

附加图像是AWS Rekognition的简单目标检测结果。 我想知道是否有人可以帮助我将响应保存到文件(CSV、文本或JSON)中

JSON文件:

with open('response.txt', 'w') as outfile:
    json.dump(response, outfile)
您可以使用pathlib模块中的Path类写入json文件

with open('response.txt', 'w') as outfile:
    json.dump(response, outfile)
from pathlib import Path
import json

json_file = json.dumps(response)
Path('file_name.json').write_text(json_file)