手机
当前位置:查字典教程网 >脚本专栏 >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实例之wxpython中Frame使用方法

python在windows下实现备份程序实例

python线程池的实现实例

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

Python中的并发编程实例

python 参数列表中的self 显式不等于冗余

python的id()函数解密过程

python的常见命令注入威胁

Python下的Mysql模块MySQLdb安装详解

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

精品推荐
分类导航