python中redis的安装和使用
作者:hebedich 时间:2021-02-21 23:19:44
python下redis安装
用python操作redis数据库,先下载redis-py模块下载地址https://github.com/andymccurdy/redis-py
shell# wget https://github.com/andymccurdy/redis-py
然后解压
在解压目录运行 python setup.py install
安装模块即可
安装完成
使用:
import redis
r = redis.Redis(host=’localhost’, port=6379, db=0)
r['test'] = ‘test’ #或者可以r.set(‘test’, ‘test’) 设置key
r.get(‘test’) #获取test的值
r.delete(‘test’) #删除这个key
r.flushdb() #清空数据库
r.keys() #列出所有key
r.exists(‘test’) #检测这个key是否存在
r.dbsize() #数据库中多少个条数
标签:python,redis
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
php实现微信公众号主动推送消息
2023-11-16 15:10:31
python中np是做什么的
2021-08-25 21:45:23
Python实现的网页截图功能【PyQt4与selenium组件】
2021-04-13 16:21:56
python pandas时序处理相关功能详解
2023-07-25 12:03:18
关于Python面向对象编程的知识点总结
2021-06-21 18:15:43
redux-saga 初识和使用
2023-07-15 16:20:17
Python 使用SFTP和FTP实现对服务器的文件下载功能
2023-10-29 09:39:40
js实现圆形菜单选择器
2023-09-23 19:50:54
![](https://img.aspxhome.com/file/2023/8/56308_0s.jpg)
如何设计注册激活邮件
2010-01-12 13:14:00
![](https://img.aspxhome.com/file/UploadPic/20101/12/2010-01-03_163629-89s.png)
Python subprocess库的使用详解
2021-10-25 04:59:32
python requests.post带head和body的实例
2022-07-12 01:22:59
python嵌套函数使用外部函数变量的方法(Python2和Python3)
2022-05-16 20:29:25
Python中的文件和目录操作实现代码
2022-08-30 15:12:11
Python过滤序列元素的方法
2023-07-05 17:53:37
Python实现暴力破解有密码的zip文件的方法
2023-11-22 22:48:40
![](https://img.aspxhome.com/file/2023/5/106975_0s.png)
python 如何快速复制序列
2022-12-04 05:20:36
![](https://img.aspxhome.com/file/2023/5/81845_0s.png)
利用python实现周期财务统计可视化
2022-03-19 21:30:41
![](https://img.aspxhome.com/file/2023/0/69450_0s.jpg)
Python基础之模块详解
2023-02-24 23:23:52
![](https://img.aspxhome.com/file/2023/2/68432_0s.png)
python机器学习Github已达8.9Kstars模型解释器LIME
2022-06-21 13:38:28
![](https://img.aspxhome.com/file/2023/2/90912_0s.png)
解析ASP与SQL server互操作的时间处理
2008-05-17 11:57:00