@TOC
本章主题
关键词
Python操作Redis
redispy安装及连接
安装Redis扩展
pip install redis
连接
r = redis.StrictRedis(host='localhost',port=6379,db=0)
字符串相关操作
import redis
class TestString(object):
def __init__(self):
self.r = redis.StrictRedis(host='192.168.75.130',port=6379)
设置值
def test_set(self):
res = self.r.set('user1','juran-1')
print(res)
取值
def test_get(self):
res = self.r.get('user1'