Skip to content

Latest commit

 

History

History
22 lines (20 loc) · 701 Bytes

File metadata and controls

22 lines (20 loc) · 701 Bytes

运行前必备: 下载并安装 redis-py

示例代码

#!/usr/bin/env python 
#-*- coding: utf-8 -*- 
import redis 
#这里替换为连接的实例 host 和 port 
host = '192.xx.xx.195' 
port = 6379 
#这里替换为实例 password 
pwd='password' 
#连接时通过 password 参数指定 AUTH 信息 
r = redis.StrictRedis(host=host, port=port, password=pwd) 
#连接建立后就可以进行数据库操作,请参见 https://github.com/andymccurdy/redis-py 
r.set('name', 'python_test'); 
print r.get('name')

运行结果