我使用了以下代码:
import MySQLdb
import base64
from PIL import Image
import cStringIO
db = MySQLdb.connect(host="localhost",
user="root",
passwd="root",
db="test")
# select statement with explicit select list and where clause instead of select * ...
sql1='select img from images where id=1'
cursor = db.cursor()
cursor.execute(sql1)
data2=cursor.fetchall()
cursor.close()
db.close()
file_like=cStringIO.StringIO(base64.b64decode(data2[0][0]))
img1=Image.open(file_like,mode='r').convert('RGB')
img1.show()
一切正常。如何使用 html 文件显示此图像
你能把代码发给我吗,如果有的话