Python 要使用 redis,需要先安装 redis 模块:
1、安装redis库
pip3 install redis |
2、测试是否安装成功:
(base) chenjd:~ xqdd$ python Python 3.7.1 (default, Dec 14 2018, 13:28:58) [Clang 4.0.1 (tags/RELEASE_401/final)] :: Anaconda, Inc. on darwin Type "help", "copyright", "credits" or "license" for more information. >>> >>> import redis >>> r = redis.StrictRedis(host='127.0.0.1',port=6379, db=0) >>> r.set('hello','World!') True >>> r.get('hello') b'World!' |