【发布时间】:2020-05-06 09:13:31
【问题描述】:
我正在向网络服务器创建删除请求并尝试捕获如下异常:
try:
response = req.delete(path, auth=HTTPBasicAuth(config.user(), config.password()), params=params, headers=headers, verify=True)
except requests.HTTPError as he:
raise SystemExit(he)
except requests.ConnectionError as ce:
raise SystemExit(ce)
except requests.URLRequired as ue:
raise SystemExit(ue)
except requests.Timeout as te:
raise SystemExit(te)
except requests.RequestException as err:
print('Undefined error: ', err)
print(response.status_code)
但删除未处理,response.status_code 打印 400,但错误处理不起作用。任何想法为什么错误处理在那里不起作用?
【问题讨论】:
标签: python-2.7 python-requests