无法使用Python在Redis中使用ZADD(排序集合)插入数据

2024-06-25 06:41:19 发布

您现在位置:Python中文网/ 问答频道 /正文

我想在redis中使用python将数据插入到排序集中,以执行复杂的查询,如范围等

import redis
redisClient = redis.StrictRedis(host='localhost', port=6379,db=0)

redisClient.zadd("players",1,"rishu")

但是当我运行上面的代码时,我得到如下错误

AttributeError: 'str' object has no attribute 'items'

我在这里做错了什么。用这个链接作为参考 https://pythontic.com/database/redis/sorted%20set%20-%20add%20and%20remove%20elements


Tags: 数据代码importredislocalhosthostdb排序