python读取BLOB格式数据

python读取BLOB格式数据

如图,数据库里存的该格式

if __name__ == '__main__':
sql = 'select data from test where id = x'
db_connect = MySQLdb_connect()
cup [ ] t j ?rsor = db_connect.cursor()
cursor.execute(sql)
content = cursor.fetchone()
print content    # 元组,content[0]就变成了字符串
data = gzip.decompress(content).decode("uw * l Z l _ :tf-8")
cursor.close(r K Q / h .)
f = open('test','w')
f.write(data)
f.close()

数据是用gzip压缩的,但是读出来不是byte格式数据、、、、求助,是不是读取方法不对

回答

调试下看看gzip.decompress(content)是什么,是不是合法的u9 9 0 / ,tf-8字符串