用Python加载图像(错误)

时间:2009-12-30 16:44:29

标签: python image

我想加载图片,但收到错误消息。

我的代码:

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

我收到此错误:

Traceback (most recent call last):
  File "D:\Python26\PYTHON-PROGRAMME\00000000000000000", line 2, in <module>
    im = Image.open("D:\Python26\PYTHON-PROGRAMME\bild.jpg")
  File "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'

1 个答案:

答案 0 :(得分:9)

你需要逃避反斜杠:

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