我正在编写一个脚本以发布到URL。对帖子的响应会将我需要的JSON返回到一个变量中,然后可以用它执行其他操作。由于我是python的新手,因此我遇到了一些问题,由于我的Google搜寻到目前为止没有使任何有用的东西,因此需要向正确的方向进行一些调整。
这是我目前的脚本: 汇入要求 响应= request.post('https://url.com/record/add-record.json?auth-id=0000&auth-password=thepasswordgoeshere&name=joe&type=boxer&host=yes&record=added&time=now') 打印响应
import requests
response = requests.post('https://url.com/record/add-record.json?auth-id=0000&auth-password=thepasswordgoeshere&name=joe&type=boxer&host=yes&record=added&time=now')
print response
# this returns: <Response [200]>
# but if I run a curl from the commandline it also returns the following JSON:
# {"status":"Success","statusDescription":"The record was added successfully.","data":{"id":123456789}}
我怎么得到这个:
{"status":"Success","statusDescription":"The record was added successfully.","data":{"id":123456789}}
放入变量?
谢谢