python学习之路-消除拦路虎

在Python学习过程中遇到SSL证书验证失败的问题,错误显示为CERTIFICATE_VERIFY_FAILED。问题源于Python 3.x版本不再使用Apple提供的OpenSSL库。解决方案是在终端运行特定的命令脚本来安装certifi提供的证书。完成这一步骤可以确保Python的ssl模块使用正确的信任证书。
摘要由CSDN通过智能技术生成
import urllib.request
page = urllib.request.urlopen("https://www.baidu.com")
text = page.read().decode("utf8")

print(text)

报错:
Traceback (most recent call last):
File “/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/urllib/request.py”, line 1348, in do_open
h.request(req.get_method(), req.selector, req.data, headers,
File “/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/http/client.py”, line 1283, in request
self._send_request(method, url, body, headers, encode_chunked)
File “/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/http/client.py”, line 1329, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File “/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/http/client.py”, line 1278, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File “/Librar

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值