为Python安装Redis库,登录 https://github.com/andymccurdy/redis-py 后点击Download ZIP下载安装包。python
解压并安装:git
git clone https://github.com/andymccurdy/redis-pygithub
cd redis-pyredis
sudo python ./setup.py installide
安装完成后,就能够引用redis库了。utf-8
#!/usr/bin/python# -*- encoding: utf-8 -*-import redis r = redis.Redis(host='127.0.0.1', port=6379) r.set('foo', 'bar') print(r.get('foo'))
// barget