python PIL image.open()错误 [英] python PIL image.open() error
问题描述
您好,我正在使用PIL打开图像,但是有这样的错误; 追溯(最近一次通话):
hello i'm using PIL to open images but there are such errors like this; Traceback (most recent call last):
File "/Users/minsw0810gmail.com/Desktop/GUIAccidentAlarm.py", line
142, in <module>
filename1 = Image.open('횡단보도상_100x100.jpg', "rb")
File
"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-
packages/PIL/Image.py", line 2462, in open
raise ValueError("bad mode %r" % mode)
ValueError: bad mode 'rb'
[Finished in 0.8s with exit code 1]
[shell_cmd: python -u
"/Users/minsw0810gmail.com/Desktop/GUIAccidentAlarm.py"]
[dir: /Users/minsw0810gmail.com/Desktop]
[path: /usr/bin:/bin:/usr/sbin:/sbin]
*횡단보도상_100x100.jpg是韩文 我的代码是
*횡단보도상_100x100.jpg is korean and my code is
文件名1 = Image.open('횡단보도상_100x100.jpg')
filename1 = Image.open('횡단보도상_100x100.jpg')
推荐答案
Image.open()仅支持将"r"作为模式参数,并为其他所有内容引发异常.
Image.open() only supports "r" as mode parameters and throws an exception for everything else.
这是文档中关于此参数的内容:
Here is what the doc says about this parameter:
mode-模式.如果指定,则此参数必须为"r".
mode – The mode. If given, this argument must be "r".
有关更多信息,请参见以下链接:
For more information here is the link:
http://pillow.readthedocs .io/zh-CN/3.4.x/reference/Image.html#PIL.Image.open
我希望这可以为您提供帮助.
I hope this can help you.
这篇关于python PIL image.open()错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!