tencent cloud


Python Connection Sample

Last updated: 2021-07-01 15:49:30

Preparations before running:
Download and install redis-py.

Sample code:

#!/usr/bin/env python 
#-*- coding: utf-8 -*- 
import redis 
#Replace with the host address and port number of the instance to be connected 
host = '192.xx.xx.195' 
port = 6379 
#Replace with the password of the instance to be connected 
#When connecting, specify the AUTH information through the "password" parameter. 
r= redis.StrictRedis(host=host, port=port, password=pwd)
#Database operations can be performed after the connection is established. For more information, please visit https://github.com/andymccurdy/redis-py. 
r.set('name', 'python_test'); 
print r.get('name')

Execution results:

Contact Us

Contact our sales team or business advisors to help your business.

Technical Support

Open a ticket if you're looking for further assistance. Our Ticket is 7x24 avaliable.

7x24 Phone Support