在python3上使用tkinter打开图像

2024-09-27 20:16:32 发布

您现在位置:Python中文网/ 问答频道 /正文

我在Python 3上编写了以下(非常简短)代码:

from tkinter import *
from PIL import Image, ImageTk

image = Image.open("Trollface.jpg")
photo = ImageTk.PhotoImage(image)
canvas.create_image(0, 0, image = photo)

当我运行它时,我只得到以下错误:

^{pr2}$

我做错什么了?在


Tags: 代码fromimageimportpiltkintercreateopen

热门问题