#!/usr/bin/python#!coding:utf-8ImportRedisif __name__=="__main__": Try: Conn=redis. Strictredis (host='192.168.80.128', port=6379,db=0)Print(Conn.ping ()) Conn.hset ('persons:001','name','Jiangle') #make hash table persons:001 name keyword (key) associated to a value of ' Jiangle 'name=conn.hget ('persons:001','name') Print(name)#Remove the value associated with the name keyword of the hash table persons:001 Print(Conn.hgetall ('persons:001')) #get all the key values in the hash table persons:001 Print(Conn.hexists ('persons:001','name')) #determine if the hash table persons:001 exists name this key Print(Conn.hget ('persons:001',' Age')) Conn.hincrby ('persons:001',' Age', 2) Print(Conn.hget ('persons:001',' Age')) #Self-incrementConn.hdel ('persons:001',' Age') Print(Conn.hkeys ('persons:001')) #Delete key exceptException as err:Print(ERR)
Pythonr Operation Redis-hash