This is a question about how to store Python json returns.

Asked 1 years ago, Updated 1 years ago, 60 views

https://developers.naver.com/docs/clova/api/CFR/API_Guide.md#Python

We are developing a program to compare face recognition values using Naver's open api service at the address above address.

It's just one of the courses I want to do, so I'm developing a server by googling here and there.

If you go to the address above, we will use Python code in the implementation example to receive a response in the form of json on the vcode and compare the analysis values in the form of json for each user.

To do that, the response code below is not directly shown in the form of json as a server I hope that the value of json type, which was analyzed by the server itself, will be saved as json type.

import os
import sys
import requests
client_id = "YOUR_CLIENT_ID"
client_secret = "YOUR_CLIENT_SECRET"
url = "https://openapi.naver.com/v1/vision/face" // Face Detection
files = {'image': open('YOUR_FILE_NAME', 'rb')}
headers = {'X-Naver-Client-Id': client_id, 'X-Naver-Client-Secret': client_secret }
response = requests.post(url,  files=files, headers=headers)
rescode = response.status_code
if(rescode==200):
    print (response.text)
else:
    print("Error Code:" + rescode)

This is because the key is to compare the data stored in json by recalling it from Python.

The above code part is not returned directly to the server in json form by which part should be modified.

Can I save it in json format where the server is located?

I want to save the returned value in json form and compare it with json = json.

When you run the server, the above code is executed and the analysis value in the form of json is returned. If you don't understand the code itself, please refer to the url at the top of the question.

json python vscode node.js

2022-09-22 19:51

2 Answers


with open('res.json', 'wt') as f:
  f.write(response.text)


2022-09-22 19:51

I also called it from NAVER APi, and I copied and pasted the result from the visual code - I saved it as a json file in the file settings. I don't know how to save it automatically ㅠ<


2022-09-22 19:51

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.