Pythonr Operation Redis-hash

Source: Internet
Author: User
Tags delete key

#!/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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.