def getPic(name,url):
# name ---图片地址
# url ---图片名字(自定义)
# 解决SSL验证
ssl._create_default_https_context = ssl._create_unverified_context
# 请求图片
resp = urllib.request.urlopen(url)
image = np.asarray(bytearray(resp.read()), dtype="uint8")
image = cv2.imdecode(image, cv2.IMREAD_COLOR)
cv2.imwrite(name, image)
# cv2.imshow(name, image)
# cv2.waitKey()
return image
python_获取网页上的图片
最新推荐文章于 2025-10-14 11:39:52 发布
本文介绍了一个使用Python进行图片下载及处理的函数。该函数通过指定的URL获取图片,并将其保存为本地文件。同时,文章展示了如何利用OpenCV库对图片进行解码和展示,为图像处理和计算机视觉应用提供了基础。
3959

被折叠的 条评论
为什么被折叠?



