博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
python操作redis-hash
阅读量:4331 次
发布时间:2019-06-06

本文共 893 字,大约阅读时间需要 2 分钟。

#!/usr/bin/python#!coding: utf-8import redisif __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)

 

转载于:https://www.cnblogs.com/JiangLe/p/5403276.html

你可能感兴趣的文章
对团队成员公开感谢博客
查看>>
教你如何在博客里加入分享功能——分享插件(HRshare)
查看>>
linux C多线程编程
查看>>
js 冒泡排序法,及双冒泡法
查看>>
[React] {svg, css module, sass} support in Create React App 2.0
查看>>
[SCSS] Organize SCSS into Multiple Files with Partials
查看>>
[Redux] React Todo List Example (Adding a Todo)
查看>>
[AngularJS] Accessing The View-Model Inside The link() When Using controllerAs
查看>>
Zabbix实战-简易教程(3)--DB安装和表分区
查看>>
Two Sum leetcode java
查看>>
Val编程
查看>>
Python多线程与多线程中join()的用法
查看>>
P2915 [USACO08NOV]奶牛混合起来Mixed Up Cows
查看>>
无向图的强连通分量
查看>>
Service之来电监听(失败的案例)
查看>>
scala编程第16章学习笔记(4)——List对象的方法
查看>>
charles之抓包和断点
查看>>
在chrome中屏蔽百度推荐
查看>>
1083Moving Tables
查看>>
linux下yum安装redis以及使用
查看>>