#!/usr/bin/python#-*- coding:utf-8 -*-# by zmokeimport redisimport json#使用redis poolpool = redis.ConnectionPool(host="*",port=6379,password='*')r = redis.Redis(connection_pool=pool)#直接连接使用api# r = redis.Redis(host='*',port=6379,password='*')print(r.keys())#info 指定参数print(r.info(section='clients'))print(r.info(section='Keyspace'))#info 不指定参数,默认所有信息# print(r.info())# getset() 方法,返回旧值,同时赋洗你的值r.set('test',1111)print(r.get('test'))r.getset('test','this is new value')print(r.get('test'))#getrang() 子串(偏移量:offset: 0代表开始,-1代表结束)print(r.getrange('test',-3,-1))#setrange()替换子串(从偏移量开始)r.setrange('test',0,'change')print(r.get('test'))#mset()一次设置多个键的值r.mset({'pig':'111','ca':'222','app':'333'})print(r.info(section='Keyspace'))#mget()一次取多个键的值print(r.mget(['pig','app']))#delete 删除键r.delete('pig')print(r.get('pig'))#批量删除DelList=r.keys('*')for key in DelList:    r.delete(key)