How to push a whole sequence to redis in Python [d

2019-04-26 21:57发布

问题:

This question already has an answer here:

  • Redis: How to parse a list result 4 answers

I can use Redis.rpush('key', 1, 2, 3) to push three elements to redis, but if there is a sequence:

seq = [1, 2, 3]

Redis.rpush('key', seq)

It will push a 'seq' element to redis but not the three number. Is there any way I can push the whole sequence to redis?

回答1:

You can use this:

Redis.rpush('key', *seq)

More at SO.