# pip install redis import redis # 创建redis连接 r = redis.Redis(host='localhost', port=6379, db=0) # 设置键值对 r.set('name', 'John') # 获取键值 name = r.get('name') print(name)