2024-04-20 14:30:21 发布
网友
我有一个编码为数据url的图像。你知道吗
如何在python中显示来自此的原始图像?你知道吗
您可以使用Tkinter打开一个用于查看图像的窗口,使用urllib读取图像数据,例如
import io import base64 try: import Tkinter as tk from urllib2 import urlopen except ImportError: import tkinter as tk from urllib.request import urlopen root = tk.Tk() image_url = "data:image/png;base64,iVB........" image_byt = urlopen(image_url).read() image_b64 = base64.encodestring(image_byt) photo = tk.PhotoImage(data=image_b64) cv = tk.Canvas(bg='white') cv.pack(side='top', fill='both', expand='yes') cv.create_image(10, 10, image=photo, anchor='nw') root.mainloop()
您可以使用Tkinter打开一个用于查看图像的窗口,使用urllib读取图像数据,例如
相关问题 更多 >
编程相关推荐