You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
502 B
26 lines
502 B
from redis import StrictRedis
|
|
|
|
if __name__=="__main__":
|
|
try:
|
|
sr = StrictRedis()
|
|
res = sr.set('name', 'itheima')
|
|
print(res) # True
|
|
|
|
res = sr.get('name')
|
|
print(res) # b'itheima'
|
|
|
|
res = sr.set('name', 'itheima2')
|
|
print(res) # True
|
|
|
|
res = sr.delete('name')
|
|
print(res) # 1
|
|
|
|
res = sr.delete('a1', 'a2')
|
|
print(res) # 0
|
|
|
|
res = sr.keys()
|
|
print(res)
|
|
except Exception as e:
|
|
print(e)
|
|
|