python3 redis 返回字节(bytes)而不是字符串(string)
最近项目更新到python3, redis版本也更新到3.4.1,使用redis的keys,smemers等命令,发现返回的数据都是字节(bytes)。
解决方法:
直接使用StrictRedis
conn = StrictRedis(host='localhost', port=6379, db=0,decode_responses=True)
如果使用池进行连接,则需要在ConnectionPool上进行设置,否则返回的数据还是字节数据
pool = redis.ConnectionPool(host='localhost',port=6379, password=REDIS_PWD, decode_responses=True)