python解析接口報錯:HTTPSConnectionPool(host=‘qyapi.weixin.qq.com‘, port=443) Name or service not known
python解析企业微信接口報錯:HTTPSConnectionPool(host='qyapi.weixin.qq.com', port=443) Name or service not known
·
HTTPSConnectionPool(host=‘qyapi.weixin.qq.com’, port=443): Max retries exceeded with url: /cgi-bin/webhook/send?key=287247b7-7fb8-4a7a-b987-215b898a201b (Caused by NewConnectionError(‘<urllib3.connection.HTTPSConnection object at 0x7f8ad4d0a9b0>: Failed to establish a new connection: [Errno -2] Name or service not known’))
使用while和try catch 处理
当请求成功时,直接出结果,如果失败,那就一直重试,直到成功为止
while True:
try:
response = requests.post(rbt_key, headers=headers, json=data)
print(response.json())
return response.json()
except Exception as e:
print(e)
time.sleep(5)

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。
更多推荐
所有评论(0)