我想在不同的数据库中写入一些值,这是我的代码:
import redis
r1 = redis.Redis(host='127.0.0.1', port=6379, db = 'db1')
r2 = redis.Redis(host='127.0.0.1', port=6379, db = 'db2')
numList = ['4', '3', '2', '1']
for num in numList:
r1.lpush('a', num)
r2.lpush('a', 'test')
print r1.lrange('a',start=0,end=-1)
print r2.lrange('a',start=0,end=-1)
然后我得到了这个结果:
['test', '1', 'test', '2', 'test', '3', 'test', '4']
['test', '1', 'test', '2', 'test', '3', 'test', '4']
虽然我使用不同的数据库,但对于同一个键,所有的值都被放入。 谢谢您。
目前没有回答
相关问题 更多 >
编程相关推荐