Python连接redis

import redis
 
pool = redis.ConnectionPool(host='localhost', port=6379,encoding="UTF-8",decode_responses=True)
r = redis.Redis(connection_pool=pool)
result = r.keys("*")

#遍历所有元素
for res in result:
    print(res)

#查看长度
print(len(result)) 

posted @ 2019-10-28 13:25  hank-li  阅读(192)  评论(0编辑  收藏  举报