import redis
'''
conn = redis.Redis(host="10.100.30.30", port=7002,password="")
conn.set("x1","hello",ex=5) # ex代表seconds,px代表ms
val = conn.get("x1")
conn.delete("x1")
print(val)
'''
pool = redis.ConnectionPool(host='10.100.30.30', port=7001, decode_responses=True)
r = redis.Redis(host='10.100.30.30', port=7001, decode_responses=True)
#r.set('name', 'runoob') # 设置 name 对应的值,
#print(r.get('PAYXW_TOKEN_KEY_payXw-private01')) # 取出键 name 对应的值,字典类型取值
#print(r.hget('PAYXW_TOKEN_KEY_payXw-private01','cntrKey'))
#print(r.hkeys('PAYXW_TOKEN_KEY_payXw-private01'))#哈希取值
print(r.lindex("rateLimit_payCmbN_deputeQry_2021041414003274",0)) #list类型数据,取值
print(r.lrange("rateLimit_payCmbN_deputeQry_2021041414003274",0,-1))#获取列表所有内容
参考学习地址
https://www.runoob.com/w3cnote/python-redis-intro.html