1、通过pip在Python中安装Redis的驱动程序。
在cmd命令中输入:python -m pip install redis

2、测试代码
#coding=utf-8
# 测试Redis
import redis
# 连接redis,加上decode_responses=True,写入的键值对中的value为str类型,不加这个参数写入的则为字节类型。
# 连接池方式
pool = redis.ConnectionPool(host='localhost', port=6379, decode_responses=True)
r = redis.Redis(connection_pool=pool)
r.set('user_name','jzh')
print(r.get('user_name'))
# 普通连接
client = redis.Redis(host='localhost', port=6379, decode_responses=True)
client.set('user_code','9001')
print(client.get('user_code'))
											