#1 连接redis
#1 连接redis -- import redis -- 使用端口连接redis conn = redis.Redis(host="127.0.0.1", port=6379) -- 使用套接字连接 r = redis.Redis(unix_socket_path='/tmp/redis.sock') -- 使用连接池连接到redis >>> pool = redis.ConnectionPool(host='192.168.56.100', port=6379) >>> conn = redis.Redis(connection_pool=pool) -- 写入一条字符串数据 conn.set("ranking:category", "hello")