python中redis使用

 用python操做redis数据库,先下载redis-py模块python

下载地址https://github.com/andymccurdy/redis-pygit

在解压目录运行 python.exe setup.py install安装模块github

使用:redis

import redis数据库

r = redis.Redis(host=’localhost’, port=6379, db=0)ide

r['test'] = ‘test’ #或者能够r.set(‘test’, ‘test’) 设置keyspa

r.get(‘test’)  #获取test的值get

r.delete(‘test’) #删除这个keyit

r.flushdb() #清空数据库io

r.keys() #列出全部key

r.exists(‘test’) #检测这个key是否存在

r.dbsize() #数据库中多少个条数

相关文章
相关标签/搜索