zcsnbb
V2EX  ›  Redis

Python redis

  •  
  •   zcsnbb · Oct 28, 2018 · 4399 views
    This topic created in 2948 days ago, the information mentioned may be changed or developed.

    我想请教一下 python 操作 redis 使用 redis.StrictRedis 创建的 redis 对象 使用 redis.zrangebyscore 能够指定获取多少条数据吗,我没发现有 limit 这个参数 但是直接操作 redis 的话是可以的 如果可以指定获取的数目的话 要怎么操作呢 (已传入最大最小值)

    2 replies  •  2018-10-29 10:56:17 +08:00
    atx
    atx
    Oct 28, 2018
    1
    https://redis-py.readthedocs.io/en/latest/#redis.StrictRedis.zrangebyscore

    zrangebyscore(name, min, max, start=None, num=None, withscores=False, score_cast_func=<type 'float'>)

    `If start and num are specified, then return a slice of the range.`

    试试这个
    zcsnbb
    zcsnbb
    OP
    Oct 29, 2018
    2
    @lc1450 num 就相当于 limit 了是吗,可是如果我想要的是指定分数前面的多少条数据是不是就没有办法了==
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   4610 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 33ms · UTC 03:42 · PVG 11:42 · LAX 19:42 · JFK 22:42
    ♥ Do have faith in what you're doing.