python - 操作系统错误 : [Errno 22] Invalid Argument: '\u202aC:/Users/.../Documents/Python/fish.jpg'

标签 python image python-imaging-library show

<分区>

File = "C:\Python\lib\site-packages\PIL\Image.py", line 2580, in open
    fp = builtins.open(filename, "rb")

此代码在我家运行良好,但在我学生的计算机上运行失败并出现标题错误。 Windows 10。新安装 Python 3.7,使用命令提示符通过 pip 新安装 Pillow,使用插件“脚本”新安装 Atom。以前有人见过这种情况吗? (下面的代码是一个简单的图像混合示例)。

(...代表用户名文件夹,每台电脑不一样。)

from PIL import Image

def main():

    size = width, height = 1080, 720

    imageOne = Image.open("C:/Users/.../Documents/Python/fish.jpg")
    imageTwo = Image.open("C:/Users/.../Documents/Python/tropicalfish.jpg")

    imageOne.thumbnail(size)
    imageTwo.thumbnail(size)

    imageOne.convert("RGB")
    imageTwo.convert("RGB")

    imageBlend = Image.blend(imageOne, imageTwo, .5)

    imageBlend.show()

    del imageOne, imageTwo, imageBlend

if (__name__ == "__main__"):

    main()

最佳答案

您的路径中有\u202a 字符。尝试删除一些首字母并手动重写。并尝试使用像这样的语法 r'C:/Users/

关于u202a - https://www.fileformat.info/info/unicode/char/202a/index.htm

关于python - 操作系统错误 : [Errno 22] Invalid Argument: '\u202aC:/Users/.../Documents/Python/fish.jpg' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51663567/

相关文章:

python - 优化将值转换为 0 和 1 的性能

python - 如何正确舍入 numpy float 组

image - 在 http golang 中提供来自字符串的图像

ios - 如何获取从 UIImagePicker 拍摄的图片的资源 URL

image - canvas draw图像质量

python - 在两行之间添加空间

python - 如何仅将节点保留在具有 2+ 个出边或 0 个出边的 networkx-graph 中?

java - 将大于 127 的值存储在字节数组中

python-3.x - 如何传递/读取 PIL.JpegImagePlugin.JpegImageFile 对象?

python - 将 numpy 数组转换为 rgb 图像