python连接redis

from redis import Redis
连接Redis()
redi = Redis()
import redis, json
rs = redis.Redis(host='127.0.0.1', port=6379, db=5)


def updatespgood(spinfo):
spcode = spinfo["spcode"]
rs.set(spcode, json.dumps(spinfo))


def getthespdata(spcode):
spdata = rs.get(spcode)
if spdata:
return json.loads(spdata)
else:
return spdata

redi.get(photoPath)
redi.set(photo, base64.b64encode(img.read()))





原文地址:https://www.cnblogs.com/wuqingzangyue/p/5770035.html