I am using Python as client to interact with redis and using the following Python library to do so: https://github.com/redis/redis-py
When I run the command:
redis_return = conn.hgetall('my-hash-key')
What I get in return is a dictionary with all its elements as bytes objects individually, like:
{b'key1': b'value1', b'key2': b'value2'}
Since I need them as string I am looping over the dictionary and on each iteration decoding they key and value, something like:
mydict = dict()
for keys in redis_return:
mydict[keys.decode('utf-8')] = redis_return[keys].decode('utf-8')
I am getting the results in mydict as I need it, but is this the right approach? Seems tedious and I wonder if there is a better way?