Home > Backend Development > Python Tutorial > Introduction to the installation and use of redis in python

Introduction to the installation and use of redis in python

高洛峰
Release: 2017-03-23 17:25:39
Original
1583 people have browsed it

Redis installation under python
Use python to operate the redis database, first download the redis-py module download address https://github.com/andymccurdy/redis-py

shell# wget <a href="https://github.com/andymccurdy/redis-py
" target="_blank">https://github.com/andymccurdy/redis-py[/code]
然后解压

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

安装完成

使用:

import redis  
   
r = redis.Redis(host=’localhost’, port=6379, db=0)  
   
r[&#39;test&#39;] = ‘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的方法 标签: pythonredis
Copy after login

The above is the detailed content of Introduction to the installation and use of redis in python. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template