Redis: How to parse a list result

前端 未结 3 375
不思量自难忘°
不思量自难忘° 2020-12-29 04:03

I am storing a list in Redis like this:

redis.lpush(\'foo\', [1,2,3,4,5,6,7,8,9])

And then I get the list back like this:

r         


        
3条回答
  •  时光取名叫无心
    2020-12-29 04:23

    I think you're bumping into semantics which are similar to the distinction between list.append() and list.extend(). I know that this works for me:

    myredis.lpush('foo', *[1,2,3,4])
    

    ... note the * (map-over) operator prefixing the list!

提交回复
热议问题