代码:
# __author__ = 'STEVEN' import redis # 方式1,直接连接 # r = redis.Redis(host='192.168.43.22',port=6379) # r.set('name','lisi') # print(r.get('name').decode()) # 方式2,创建进程池连接 poll = redis.ConnectionPool(host= '192.168.43.22',port=6379) #选择进程池 r = redis.Redis(connection_pool=poll) r.set('age','20') print(r.get('age').decode())
友情链接:
redis官方文档(http://www.runoob.com/redis/connection-select.html)