zoukankan      html  css  js  c++  java
  • python操作redis-hash

    #!/usr/bin/python
    #!coding: utf-8
    
    import redis
    
    
    
    if __name__=="__main__":
        try:
            conn=redis.StrictRedis(host='192.168.80.128',port=6379,db=0)
            print(conn.ping())
    
            conn.hset('persons:001','name','jiangle')
                #让hash表persons:001的name关键字(key)关联到一个值‘jiangle’
    
            name=conn.hget('persons:001','name')
            print(name)
                #取出hash表persons:001的name关键字所关联的值
    
            print(conn.hgetall('persons:001'))
                #取得hash表persons:001中所有的键值
    
            print(conn.hexists('persons:001','name'))
                #判断hash表persons:001是否存在name这个键
    
            print(conn.hget('persons:001','age'))
            conn.hincrby('persons:001','age',2)
            print(conn.hget('persons:001','age'))
                #自增
    
            conn.hdel('persons:001','age')
            print(conn.hkeys('persons:001'))
                #删除键
        except Exception as err:
            print(err)
  • 相关阅读:
    codeforces
    hdu
    hdu
    poj 2823
    hdu
    hdu
    hdu
    微信公众号 SDK
    PHP 正则表达式
    注册和登录时的验证码
  • 原文地址:https://www.cnblogs.com/JiangLe/p/5403276.html
Copyright © 2011-2022 走看看