使用 Python 在 Redis 中增加哈希字段的值

Increment value of a hash field in Redis using Python

我在python中的redis中创建了一个hash如下:

r.hmset('list:123', {'name': 'john', 'count': 5})

如何增加键 list:123 的计数值?

r.hincrby("list:123", "count", 1)

使用此页面作为参考

https://redis.io/commands/hincrby

hash = 'list:123'
key = 'count'
n = 1

r.hincrby(hash, key, n)