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

我的代码:

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'

最佳答案

您需要转义反斜杠:

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

关于python - 在 Python 中加载图像(错误),我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/1981138/

10-11 19:18