python 操作redis可以直接用redis来操作,但不能用于集群模式
redis-py-cluster可以用于集群模式的连接操作
pip install redis-py-cluster
from rediscluster import StrictRedisCluster
startup_nodes = [{"host": "127.0.0.1", "port": "7000"}] # list形式添加多个服务器和端口
# Note: decode_responses must be set to True when used with python3
rc = StrictRedisCluster(startup_nodes=startup_nodes, decode_responses=True)
rc.set("foo", "bar")
print(rc.get("foo"))
具体python操作redis命令参考