手机
当前位置:查字典教程网 >脚本专栏 >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的安装和使用】相关文章:

paramiko模块安装和使用(远程登录服务器)

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

Python下的Mysql模块MySQLdb安装详解

python del()函数用法

详解Python中的__init__和__new__

python的id()函数解密过程

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

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

python生成器的使用方法

Python中的Function定义方法第1/2页

精品推荐
分类导航