首页 > 解决方案 > 如何在python中的文件夹中添加图像

问题描述

如何将图像保存在文件夹中?该文件夹来自另一个用户,该用户想要保存该图像。从用户那里获得的文件夹名称在哪里写?

标签: python

解决方案


尝试pip install opencv-python在任何命令行中使用安装 OpenCV。然后,使用下面的代码片段。

import cv2
from os import path

def saveImage(image):
    myImage
    address = input('Please enter your address here:')
    imgSaveDir = path.join(address, 'yourImagesName')
    cv2.imwrite(imgSaveDir , image)

使用此功能,您将能够将图像保存在您输入的任何目录中。


推荐阅读