redis-py 的 github 页面:https://github.com/andymccurdy/redis-py
1、获取 redis-py:支持三种方式
- pip install redis
- python setup.py install
- 从源码安装:
- Linux:wget https://github.com/andymccurdy/redis-py/archive/3.5.3.tar.gz
- Windows:curl -O -L https://github.com/andymccurdy/redis-py/archive/3.5.3.zip
- 解压,然后运行,python setup.py install
2、简单使用:
>>> import redis
>>> r = redis.Redis(host='localhost', port=6379, db=0)
>>> r.set('foo', 'bar')
True
>>> r.get('foo')
b'bar'