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

Joh*_*aul 0 python redis redis-py

hash在 python 中创建了一个in redis,如下所示:

r.hmset('list:123', {'name': 'john', 'count': 5})
Run Code Online (Sandbox Code Playgroud)

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

小智 10

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

r.hincrby(hash, key, n)
Run Code Online (Sandbox Code Playgroud)