因此,我是API的新手,但我正在尝试使用它们进行更多的练习。我的连接没问题(200),但是每当我尝试打印结果时,都会收到此错误:
{“ jsonrpc”:“ 2.0”,“错误”:{“代码”:-32700,“消息”:“解析错误”,“数据”:null},“ id”:null}
这是我的代码,其中的api键已删除:
url = 'https://api.random.org/json-rpc/1/invoke'
data = {'jsonrpc':'2.0','method':'generateIntegers','params': {'apiKey':'mykeygoeshere','n':10,'min':1,'max':10,'replacement':'true','base':10},'id':24565}
response = requests.get(url,data)
print(response.text)
感谢您的帮助
答案 0 :(得分:0)
import requests
import json
url = 'https://api.random.org/json-rpc/1/invoke'
data = {'jsonrpc':'2.0','method':'generateIntegers','params': {'apiKey':'mykey','n':10,'min':1,'max':10,'replacement':'true','base':10},'id':24565}
params = json.dumps(data)
response = requests.post(url,params)
print(response.text)