首页 > 解决方案 > 使用 Python 增加 Redis 中哈希字段的值

问题描述

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

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

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

标签: pythonredisredis-py

解决方案


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

r.hincrby(hash, key, n)

推荐阅读