解決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)
相關文章
相關標籤/搜索