Redis - 错误:值不是有效的浮点数 [英] Redis - Error: value is not a valid float
问题描述
我在 Redis 中有一个排序集.我正在尝试通过在 Python 代码中使用 Zincrby 来更新特定元素的计数器值,例如:
I have a sorted set in Redis. I am trying to update the counter value of a specific element by using zincrby in Python code like:
conn.zincrby("usersSet", float(1), "user1")
但它显示的错误为:'错误:值不是有效的浮点数'
But it is showing an error as : 'Error: value is not a valid float'
我在 cli 上尝试了相同的命令:zincrby usersSet 1 users1它工作正常.Python代码中是否有其他方法可以增加排序集中特定键的计数器值.
I tried the same command on cli : zincrby usersSet 1 users1 And it is working correctly. Is there any other method in Python code to increase the counter value of the specific key in the sorted set.
推荐答案
redis-cli 和 python 连接器的参数顺序不同.你必须写 conn.zincrby("usersSet", "user1", 1)
Parameters order are differ between redis-cli and python connector. You have to write conn.zincrby("usersSet", "user1", 1)
python redis 库已更新以匹配 redis-cli 的顺序
The python redis library was updated to match redis-cli's order of arguments.
因此,conn.zincrby("usersSet", 1, "user1")
现在将是正确的用法.
Hence, conn.zincrby("usersSet", 1, "user1")
will be the correct usage now.
这篇关于Redis - 错误:值不是有效的浮点数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!