我正在构建一个简单的python 3程序来打开图像并调整其大小。我正在使用Pycharm。我从PIL导入了Image并尝试运行以下命令:
image1 = Image.open('<file location>')
,但是解释器显示“属性错误”,即“图像”类型未打开任何属性。
我的程序是:
from PIL import Image
from tkinter import *
root = Tk()
image2 = Image.open('hp png.png')
hp_image2 = Label(root,image = image2)
hp_image2.pack(fill = BOTH)
root.mainloop()