问题遇到的现象和发生背景
用python操作redis存储中文后,再取出的数据变成了乱码怎么办?
用代码块功能插入代码,请勿粘贴截图
redis_config = {
"host": "192.168.3.6",
"port": 6379,
"db": 0
}
pool = redis.ConnectionPool(host=redis_config["host"],
port=redis_config["port"],
db=redis_config["db"])
r = redis.Redis(connection_pool=pool,charset='UTF-8',decode_responses=True,encoding='UTF-8')
m = "哈哈哈"
r.hset("hash3", "title", m)
x = r.hmget("hash1", "title")
print(x)
运行结果及报错内容
[b'\xe5\x93\x88\xe5\x93\x88\xe5\x93\x88']