📜  将请求响应 json 保存到文件 python 代码示例

📅  最后修改于: 2022-03-11 14:47:14.193000             🧑  作者: Mango

代码示例1
import requests
# there is inbuilt json() constructor for requests.get() method
json_data = requests.get("https://api.blinkist.com/v4/books/5420831a63656400089f0000").json()
print(json_data)

# To actually write the data to the file, we just call the dump() function from json library
import json
with open('personal.json', 'w') as json_file:
    json.dump(json_data, json_file)