在我的代码中,我提出了一些发布请求。如何在该调用中捕获连接拒绝错误?
try:
headers = {'content-type': 'application/x-www-form-urlencoded; charset=UTF-8'}
response = requests.request("POST", local_wallet_api + "v1/wallet/get_public_keys", headers=headers)
res = json.loads(response.text)
except Exception as e:
if e.errno == errno.ECONNREFUSED:
print("connection refused")
sys.exit(141)
我已经尝试了上面的代码,但它不起作用,因为它说e没有errno参数。有没有正确的方法来处理这种错误?
慕森王
芜湖不芜
冉冉说
相关分类