Python关于https请求requests.exceptions.SSLError解决方案

在使用requests请求https接口时,报以下错误:

requests.exceptions.SSLError

 

解决方案:

1.在请求中加verify=False,意思是当我们测试接口的协议为https时,关闭认证

res = requests.post('https://...', headers=headers, json=param_dict, verify=False)

2.关闭认证后还需要加入以下代码,不然控制台还会给出警告

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

 

posted @ 2020-12-18 16:04  黑框眼镜_Ethan  阅读(187)  评论(0)    收藏  举报