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!' |