嗨,在我从查询中得到blob后,我的类型有问题,下面是代码conn = MySQLdb.connect("mysqlblah", "user", "pass", "db")
cursor = conn.cursor()
data = []
queryString = "SELECT * FROM contentindex where tag LIKE '" + contentType + "%'"
cursor.execute(queryString)
rows = cursor.fetchall()
columns = [t[0] for t in cursor.description]
for row in rows:
jsonRow = {}
i = 0
for column in columns:
if column == "created":
jsonRow[column] = str(row[i])
elif column == "icon":
icon = row[i]
print icon
jsonRow[column] = "data:image/(jpg);base64," + base64.b64encode(icon.getvalue())
else:
jsonRow[column] = row[i]
i = i + 1
data.append(jsonRow)
这将打印<_io.bytesio object at>,然后抛出'str' object has no attribute 'getvalue'异常。在
我为这个问题忙了好几天,任何帮助都将不胜感激