必须安装python3以上 

     redis API ---python

    redis API ---python

    redis API ---python

    配置文件自己下载,搜索名字百度

    解压---->Python  --->./configure-->yum install -y zlib* -->make  && make install 

      安装 redis-py-master

      unzip redis-py-master.zip

      进去目录里面

      python3 setup.py install
    

      安装   redis-py-cluster-unstable.zip

        unzip redis-py-cluster-unstable.zip

        进去目录里面

        python3 setup.py install

 

二 , 调用

    测试是否连接

 1 [root@db01 redis-py-cluster-unstable]# python3
 2 Python 3.6.1 (default, Nov 30 2018, 17:06:14)
 3 [GCC 4.8.5 20150623 (Red Hat 4.8.5-28)] on linux
 4 Type "help", "copyright", "credits" or "license" for more information.
 5 >>> import redis
 6 >>> r = redis.StrictRedis(host='localhost', port=6379, db=0,password='123')
 7 >>> r.set('foo', 'bar')
 8 True
 9 >>> r.get('foo')
10 b'bar'
11 >>>
View Code

相关文章: