1.安装驱动
输入命令:pip install redis
2.直接使用驱动
import redis r = redis.StrictRedis(host=‘127.0.0.1‘, port=6379, db=0) r.set(‘foo‘, ‘bar‘)
3.ORM框架——flask-redis
输入命令:pip install flask-redis
from flask import Flask from flask.ext.redis import FlaskRedis app = Flask(__name__) redis_store = FlaskRedis(app) redis_store[‘key‘] = ‘cnki‘
时间: 2024-11-05 06:25:53