3.Redis與python互動
#匯入模組、包
from redis import*
if __name__=="__main__":
try:
#1.建立StrictRedis物件,與redis伺服器建立連線
sr=StrictRedis()
#2、redis正常操作
#新增鍵py1,值為gj
result=sr.set('py1','gj')
#輸出響應結果,如果新增成功則返回True,否則返回Falseprintresult
except Exception
as e:
print e