首页 > 代码库 > Python和Redis

Python和Redis

安装redis-py

读写数据:

import redis
r=redis.StrictRedis(host=192.168.*.*,port=6379,db=0)
r.hset("person:1", "name", "zhangsan")
print(r.hget("person:1", "name"))#b‘zhangsan‘
pipe=r.pipeline()
pipe.set("a","A")
pipe.get("a")
result=pipe.execute()
print(result)#[True, b‘A‘]

 

Python和Redis