问题描述
附件图像是来自AWS Rekognition的简单对象检测结果。 我想知道是否有人可以帮助您将响应保存到文件(CSV或TEXT或JSON)。
response = client.detect_labels(
Image={ 'S3Object': {
'Bucket': 'arkladetest1','Name': photo}})
print(response)
What is the difference between globalposition and localposition in flutter?
解决方法
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)
您可以使用pathlib模块中的Path类来写入json文件。