时间:2021-07-01 10:21:17 帮助过:64人阅读
shell# wget <a href="https://github.com/andymccurdy/redis-py</pre>" target="_blank">https://github.com/andymccurdy/redis-py[/code]</a> <br>然后解压<br><br>在解压目录运行 <pre class="plain" name="code">python setup.py install</pre>安装模块即可<br><br>安装完成<br><br><b>使用:</b><br><br><pre class="py" name="code">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() #数据库中多少个条数</pre><br><br><h3>您可能感兴趣的文章:</h3><a href="/content/385464.html" target="_blank">Python读写Redis数据库操作示例</a><br><a href="http://www.gxlcms.com/article/64646.htm" target="_blank">Python与Redis的连接教程</a><br><a href="/content/385785.html" target="_blank">python连接MySQL、MongoDB、Redis、memcache等数据库的方法</a><br><a href="/content/434848.html" target="_blank">python操作redis的方法</a><br><a href="http://www.gxlcms.com/article/68264.htm" target="_blank">Redis的Python客户端redis-py安装使用说明文档</a><br><a href="/content/5450059.html" target="_blank">Python使用Redis实现作业调度系统(超简单)</a><br><a href="http://www.gxlcms.com/article/86855.htm" target="_blank">Python的Flask框架使用Redis做数据缓存的配置方法</a><br><a href="/content/7451187.html" target="_blank">python安装与使用redis的方法</a> <script type="text/javascript" src="http://staticimg.lai18.com/Public/Js/notice/10.js"></script><script type="text/javascript"> 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 src="http://cpro.baidustatic.com/cpro/ui/c.js" type="text/javascript"></script> <!-- <div class='doc-content-pic doc-pic'> <img src="http://static.lai18.com//index/docpic?type=2&class_id=" /> </div> --> 标签: pythonredis
以上就是使用python中redis的安装和使用介绍的详细内容,更多请关注Gxl网其它相关文章!