手机
当前位置:查字典教程网 >脚本专栏 >python >python中redis的安装和使用
python中redis的安装和使用
摘要:python下redis安装用python操作redis数据库,先下载redis-py模块下载地址https://github.com/an...

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的安装和使用】相关文章:

python中的列表推导浅析

python学习笔记:字典的使用示例详解

python线程池的实现实例

Python Deque 模块使用详解

python中 ? : 三元表达式的使用介绍

详解Python中的__init__和__new__

Python下的Mysql模块MySQLdb安装详解

Python中的文件和目录操作实现代码

Python中的魔法方法深入理解

Python正则表达式的使用范例详解

精品推荐
分类导航