About char b prefix in Python3.4.1 client connect to redis About char b prefix in Python3.4.1 client connect to redis python python

About char b prefix in Python3.4.1 client connect to redis


It means it's a byte string

You can use:

redis.StrictRedis(host="localhost", port=6379, charset="utf-8", decode_responses=True)

using decode_responses=True to make a unicode string.


b'Hello Python' is a byte string - redis will auto-encode a unicode string for you on the way in, but it's your job to decode it on the way out.

Better to explicitly encode and decode:

>>> redisClient.set('test_redis', 'Hello Python'.encode('utf-8'))>>> redisClient.get('test_redis').decode('utf-8')'Hello Python'