zl程序教程

您现在的位置是:首页 >  后端

当前栏目

python requests 关闭提示警告

Python 关闭 提示 警告 requests
2023-06-13 09:13:54 时间

当使用 requests 库发送请求时报了以下警告

InsecureRequestWarning: Unverified HTTPS request is being made to host 'www.xxx.com'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/1.26.x/advanced-usage.html#ssl-warnings
  warnings.warn(

如何解决

import requests

# 加上这行代码即可,关闭安全请求警告
requests.packages.urllib3.disable_warnings()