import redis
class My(object):
def __init__(self):
self.__host='118.24.3.40'#self变量前面加__,出了类就不能用了
self.__port=6379
self.__password='HK139bc&*'
self.r=redis.Redis(host=self.__host,port=self.__port,password=self.__password)
def get(self,k):
res=self.r.get(k)
if res:
return res.decode()
return None
def __close(self):#私有方法
print('close')
def str_set(self,k,v):
self.r.set(k,v)
def str_delete(self):
#str类型的删除key
pass
def hash_get(self):#hash类型获取单个key
pass
def hash_set(self):#hash类型set
pass
def hash_getall(self):#hash类型获取key里面所有的数据
pass
def hash_del(self):#hash类型删除
pass
def clean_redis(self):
pass
my=My()
print(my.__close)