1

Code

import redis
r = redis.StrictRedis(host='localhost', port=6379, db=0)

test = r.get("Name")

print (test)

Im trying to Print the value inside of "Name"

Manually Getting Key "Name"

root@Vibs:~# redis-cli
127.0.0.1:6379> get Name
"Joel"

When I Execute The Code

root@Vibs:~# python3 test.py
b'Joel'

Trying to create a database that can be set from a HTML form, then sent into variables in a python script to run on a bot for discord.

Joel
  • 37
  • 6

1 Answers1

3

Change your call to setup the Redis connection from:

r = redis.StrictRedis(host='localhost', port=6379, db=0)

to:

r = redis.StrictRedis('localhost', 6379, charset='utf-8', decode_responses=True)

The decode_responses flag tells the client to auto-convert the values from binary to a Python String. The charset indicates which charset should be used for the conversion.

More information can be found here: About char b prefix in Python3.4.1 client connect to redis

Tague Griffith
  • 3,963
  • 2
  • 20
  • 24