开发者

Loading an image in Python (Error)

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜