我正在编写一个问题的解决方案,我遇到了PIL图像方法的问题。
choice = input("Would you like to save the maze as a file, Y/N?").upper()
if choice == "Y":
canvas.update()
canvas.postscript(file="maze.eps", colormode='color')
img = Image.open("maze.eps")
但是我收到以下错误消息:
Traceback (most recent call last):
File "C:\Users\Matthew\Desktop\NEA\Technical Solution\mazeVisualiser.py", line 66, in <module>
img = Image.open("maze.eps")
AttributeError: type object 'Image' has no attribute 'open'
但是在学习PIL模块时我知道这是有效的:
from PIL import Image
img = Image.open('brick-house.png')
任何帮助都会非常感激,因为这让我完全陷入困境。
答案 0 :(得分:0)
试试这个:
import PIL.Image
fp = open("brick-house.png", "rb")
img = PIL.Image.open(fp)
img.show()