鍍金池/ 問(wèn)答/人工智能  Java  Python/ python在get redis數(shù)據(jù)時(shí)報(bào)錯(cuò)

python在get redis數(shù)據(jù)時(shí)報(bào)錯(cuò)

python & redis小白在嘗試獲取redis數(shù)據(jù)時(shí),報(bào)如圖錯(cuò)誤。網(wǎng)上查一般般都是set時(shí)候會(huì)報(bào)這樣的錯(cuò)誤,請(qǐng)個(gè)位大神指教。

clipboard.png

回答
編輯回答
胭脂淚

如果我沒(méi)記錯(cuò)的話,存取應(yīng)該這樣就行了。
from redia import Redis
cli=Redis("localhost:xxxx")
res=cli.set("id",1)
id=cli.get("id")

2018年5月15日 03:12
編輯回答
青黛色

問(wèn)題已解決。
數(shù)據(jù)插入時(shí)用的是zadd,所以在取數(shù)據(jù)時(shí)要用zrange,zrangebyscore等函數(shù)

2018年4月3日 09:25