[英]Don't understand why print does not display results of hmget
我不明白為什么打印不能使用python在redis
顯示hmget
結果
你說它,我試過了。
def newcode(R=r):
cnt = 1
for cnt in range(0,10):
rec=R.hmget('rec-'+str(cnt), 'key' , 'txt')
print(rec)
cnt += 1
這是返回的內容:
Pipeline<ConnectionPool<Connection<host=127.0.0.1,port=6379,db=0>>>
我期望類似: 1 "This is the text"
,它將顯示存儲在哈希中的鍵和文本值。
我復制你的方法,我證明它並且工作正常
import redis
import json
def newcode(R):
for cnt in range(0, 2):
rec = R.hmget('rec-' + str(cnt), 'key', 'txt')
print(rec)
conn = redis.Redis('localhost')
user = {'name': 'username','key': 25,'txt': 'football','response': 5}
meat = {'name': 'username','key': 22,'txt': 'basquetball','response': 5}
conn.hmset("rec-0", user)
conn.hmset("rec-1", meat)
newcode(conn)
輸出是:
[b'25', b'football']
[b'22', b'basquetball']
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.