一、安装redis-py的方法
使用pip install安装redis-py
C:\Users\BigJun>pip3 install redis
Collecting redis
Downloading https://files.pythonhosted.org/packages/3b/f6/7a76333cf0b9251ecf49efff635015171843d9b977e4ffcf59f9c4428052/redis-2.10.6-py2.py3-none-any.whl (64kB)
100% |████████████████████████████████| 71kB 180kB/s
Installing collected packages: redis
Successfully installed redis-2.10.6
二、redis-py的使用方法(其他API和jedis类似,不一一测试了)
import redis
client = redis.StrictRedis(host='192.168.131.132', port=6379)
key = "hello"
setResult = client.set(key, "python-redis")
print(setResult)
value = client.get(key).decode('utf8')
print(value)输出为:C:\mysoftware\Python3\python3.exe C:/mysoftware/pycharm/littlepig/little_pig.pyTruepython-redis