InsecureRequestWarning: Unverified HTTPS request is being made to host 'xx.xx.cn'. Adding certificate verification is strongly advised.
使用requests库报下面这个警告
/Users/xxxance/python_project/code.xxx.org/ad/devops_python/venv/lib/python3.9/site-packages/urllib3/connectionpool.py:1013: InsecureRequestWarning: Unverified HTTPS request is being made to host 'open.feishu.cn'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/1.26.x/advanced-usage.html#ssl-warnings warnings.warn( /Users/xxxance/python_project/code.xxx.org/ad/devops_python/venv/lib/python3.9/site-packages/urllib3/connectionpool.py:1013: InsecureRequestWarning: Unverified HTTPS request is being made to host 'open.feishu.cn'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/1.26.x/advanced-usage.html#ssl-warnings warnings.warn(
翻译提示信息后,提示信息表达的意思是:强烈不鼓励发出未经验证的 HTTPS 请求,但是,如果您了解风险并希望禁用这些警告,则可以使用
disable_warnings()
:>>> import urllib3 >>> urllib3.disable_warnings()# 等价于requests.packages.urllib3.disable_warnings()
或者,您可以使用标准
logging
模块捕获警告:>>> logging.captureWarnings(True)
最后,您可以通过设置
PYTHONWARNINGS
环境变量或使用 -W 标志来抑制解释器级别的警告 。