[python] tkinter couldn't recognize data in image file problem when calling PhotoImage

error code:

photo = PhotoImage(file='1.jpg')

PhotoImage in tkinter can only open gif files. Note: Changing the suffix of jpg to gif will not work! ! You may need to use PS or something to convert it.
I just found a gif later.

To open other pictures use the following method

from PIL import ImageTk
photo = ImageTk.PhotoImage(file='1.jpg')

Guess you like

Origin blog.csdn.net/anjue1997/article/details/115862858