【python】requests 异常处理


以下是request.exceptions下的各种异常错误:

RequestException:

HTTPError(RequestException)

UnrewindableBodyError(RequestException)

RetryError(RequestException)

ConnectionError(RequestException) ProxyError(ConnectionError)

SSLError(ConnectionError)

ConnectTimeout(ConnectionError, Timeout)

Timeout(RequestException) ReadTimeout

URLRequired(RequestException)

TooManyRedirects(RequestException)

MissingSchema(RequestException, ValueError)

InvalidSchema(RequestException,ValueError)

InvalidURL(RequestException,ValueError)

InvalidHeader(RequestException,ValueError)

ChunkedEncodingError(RequestException)

StreamConsumedError(RequestException,TypeError)

ContentDecodingError(RequestException,BaseHTTPError)

在实际应用的过程中,我们可以把请求放在try下,把可能发生的异常用except获取


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM