如何在Python中显示jpg文件?

2024-04-25 05:12:28 发布

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

def show():

    file = raw_input("What is the name of the image file? ")

    picture = Image(file)

    width, height = picture.size()

    pix = picture.getPixels()

我试图编写一个代码来显示此图像,但此代码不提供图像。 如何更改代码以显示此图像?


Tags: ofthe代码name图像imageinputraw
2条回答
from PIL import Image

image = Image.open('File.jpg')
image.show()

别忘了包括

import Image

为了显示它,请使用:

Image.open('pathToFile').show()

相关问题 更多 >