开发者

Loading an image in Python (Error)

开发者 https://www.devze.com 2022-12-15 06:46 出处:网络
I want to load an image but I get an error-message. My code: from PIL import Image im = Image.open(\"D:\\Python26\\PYTHON-PROGRAMME\\bild.jpg\")

I want to load an image but I get an error-message.

My code:

from PIL import Image
im = Image.open("D:\Python26\PYTHON-PROGRAMME\bild.jpg")
im.show()

I get this error:

Traceback (most recent call last):
  File "D:\Python26\PYTHON-PROGRAMME\00000000000000000", line 2, in <module>
    im = Image.open("D:\Python26\PYTHON-PROGRAMME\bild.jpg")
  Fil开发者_如何学编程e "D:\Python26\lib\site-packages\PIL\Image.py", line 1888, in open
    fp = __builtin__.open(fp, "rb")
IOError: [Errno 22] invalid mode ('rb') or filename: 'D:\\Python26\\PYTHON-PROGRAMME\x08ild.jpg'


You need to escape the backslashes:

im = Image.open("D:\\Python26\\PYTHON-PROGRAMME\\bild.jpg")
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号