pyhton操作redis返回中文处理

发布时间 2023-12-05 10:04:44作者: 听雨轩!

使用pyhton操作redis返回为:b'\xe4\xb8\xad\xe5\x8d\x8e\xe4\xba\xba\xe6\xb0\x91\xe5\x85\xb1\xe5\x92\x8c\xe5\x9b\xbd' 或b'Zarten_4',处理办法:

需在连接池中加入编码及字符集:

redis_conn = redis.Redis(host='127.0.0.1', port= 6379, password= '******', db= 0,decode_responses=True,charset='UTF-8',encoding='UTF-8')
或在各户端连接中加:--raw