Python操作Redis redis-py install 1 pip install redis Start a redis via docker: 1 docker run -p 6379:6379 -it redis/redis-stack:latest Quickly connecting to redis 1 2 3 4 5 import redis r = redis.Redis(host='localhost', port=6379, db=0) r.ping() r.set('foo', 'bar') r.get('foo') Connection Pools 1 2 3 4 import redis pool = redis.ConnectionPool(host='localhost', port=6379, db=0) r = redis.Redis(connection_pool=pool) r.ping() 操作