Python之Redis操作

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'

  

 

posted @ 2016-07-23 10:36  ~沐风  阅读(633)  评论(0编辑  收藏  举报