python简单操作redis

redis操作

import redis
r = redis.StrictRedis(host='localhost', port=6379, db=0)
r.set('test1', 'test1')


value1 = r.get('car')
print(value1)

all_keys = r.keys()
print(all_keys)

for indexKey in all_keys:
    indexValue1 = r.get(indexKey)
    print(indexValue1)


if r.exists("test1"):
    r.delete("test1")


all_keys = r.keys()
print(all_keys)

for indexKey in all_keys:
    indexValue1 = r.get(indexKey)
    print(indexValue1)

 

 

 

#################

posted @ 2022-08-22 07:54  西北逍遥  阅读(27)  评论(0编辑  收藏  举报