zcsnbb
V2EX  ›  Redis

Python redis

  •  
  •   zcsnbb · Oct 28, 2018 · 4256 views
    This topic created in 2834 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
        1
    atx  
       Oct 28, 2018
    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
        2
    zcsnbb  
    OP
       Oct 29, 2018
    @lc1450 num 就相当于 limit 了是吗,可是如果我想要的是指定分数前面的多少条数据是不是就没有办法了==
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2952 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 24ms · UTC 08:00 · PVG 16:00 · LAX 01:00 · JFK 04:00
    ♥ Do have faith in what you're doing.