我对发送请求和类似的东西很陌生,我尝试了一个简单的练习,即连接到Codeforce并获得响应:
https://codeforces.com/api/help,这是说明问题的帮助链接-但我真的不明白
contestId=556
secret="secretkey"
apiKey="apikey"
timeValue = time.time()
rand = random.randint(000000,999999)
hashCode = hashlib.sha512()
hashCode.update(str(""+str(rand)+"/contest.list?apiKey="+apiKey+"&contestId="+str(contestId)+"&time="+str(timeValue)+"#"+secret).encode())
conn = http.client.HTTPConnection("http://codeforces.com/api")
conn.request("GET","/contest.list?contestId="+str(contestId)+"&apiKey="+str(apiKey)+"&time="+str(timeValue)+"apiSig="+str(rand)+str(hashCode.digest()))
res = conn.getresponse()
print(res.status, res.reason)
我必须对代码进行哪些更改才能使其正常工作?任何帮助将不胜感激,已经阅读了HTTP.Client的python文档...但是很好...