python requests提示警告InsecureRequestWarning

2020-09-17 09:58:19 浏览数 (1)

在Python3中使用以下代码报错:

代码语言:javascript复制
import requests
response = requests.get(url='', verify=False)

错误代码如下:

代码语言:javascript复制
InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. 

方法:

在语句前加上以下代码即可不会被报错:

代码语言:javascript复制
import requests
requests.packages.urllib3.disable_warnings()
response = requests.get(url, verify=False)

0 人点赞