解决Python3 控制台输出InsecureRequestWarning的问题

问题:html

使用Python3 requests发送HTTPS请求,已经关闭认证(verify=False)状况下,控制台会输出如下错误:python

InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings安全

 

解决方法:url

在代码中添加如下代码便可解决:htm

import urllib3
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
 

 Python2添加以下代码便可解决:blog

from requests.packages.urllib3.exceptions import InsecureRequestWarning
# 禁用安全请求警告
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
相关文章
相关标签/搜索