#!/usr/bin/env python #_*_ coding:UTF-8 _*_ import redis import pickle #普通连接 ''' db="db1" key1="#_u_ext5#10736" r = redis.Redis(host='127.0.0.1',port=16000,password='123456',db=1,decode_responses=True) #,db=0代表选择了0号数据库 r = redis.StrictRedis(host='127.0.0.1',port=16000,password='123456',decode_responses=True) ''' host='127.0.0.1' port=16000 password='123456' #db=0代表选择了0号数据库 r = redis.StrictRedis(host=host, port=port, password=password, db=1,decode_responses=False) r.set('age', '88') #设置key re=r.get("age") print('key1',re) #取key值 key1="#_u_ext5#10736" re=r.get(key1) print('key1',re)