PHP前端开发

使用python中redis的安装和使用介绍

百变鹏仔 2个月前 (02-08) #Python
文章标签 python

python下redis安装
用python操作redis数据库,先下载redis-py模块下载地址https://github.com/andymccurdy/redis-py

shell# wget <a>" target="_blank"&gt;https://github.com/andymccurdy/redis-py[/code]</a> <br>然后解压<br><br>在解压目录运行 <pre class="brush:php;toolbar:false">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与Redis的连接教程
python连接MySQL、MongoDB、Redis、memcache等数据库的方法
python操作redis的方法
Redis的Python客户端redis-py安装使用说明文档
Python使用Redis实现作业调度系统(超简单)
Python的Flask框架使用Redis做数据缓存的配置方法
python安装与使用redis的方法            <script></script><script> var cpro_id="u2496340"; (window["cproStyleApi"] = window["cproStyleApi"] || {})[cpro_id]={at:"3",rsi0:"750",rsi1:"250",pat:"6",tn:"baiduCustNativeAD",rss1:"#FFFFFF",conBW:"1",adp:"1",ptt:"0",titFF:"%E5%BE%AE%E8%BD%AF%E9%9B%85%E9%BB%91",titFS:"14",rss2:"#000000",titSU:"0",ptbg:"90",piw:"0",pih:"0",ptp:"0"} </script>  <script></script>                           标签: pythonredis