Python redis 存取使用

1.存数据

# 连接redis, 指定库(0-15)
r = redis.StrictRedis(host='localhost', port=6379, db=0)
result_list = [1, 2, 3]
for result in result_list:
    # 指定表名,存数据
    r.sadd('school_url1', result)

2.取数据

# 取出的同时,删除
r_result = r.spop('school_url1')
 
posted @ 2020-09-23 18:33  loren880898  阅读(207)  评论(0编辑  收藏  举报