安装
https://pypi.python.org/pypi/redis/
https://github.com/andymccurdy/redis-py
参照官网,安装命令
sudo pip install redis
或者
sudo easy_install redis
亦或
源码包执行sudo python setup.py install
实例
>>> import redis >>> r = redis.Redis(host="172.16.64.175", port=6379, db=0) >>> r.keys() ['foo', 'news:1000:tags', 'c', 'a', 'mylist', 'mycounter', 'mykey', 'b'] >>> r.set('name', 'yang') True >>> r['sex'] = 'man' >>> r.get('sex') 'man' >>> r.delete('a') 1 >>> r.dbsize() 9L >>> r.save() True >>> r.flushdb() True >>> r.keys() [] >>> r.exists('name') False
原创文章,作者:奋斗,如若转载,请注明出处:https://blog.ytso.com/8978.html