abstract:python下redis安裝用python操作redis數(shù)據(jù)庫,先下載redis-py模塊下載地址https://github.com/andymccurdy/redis-pyshell# wget https://github.com/andymccurdy/redis-py然后解壓在解壓目錄運行 python setup.py install安裝模塊即可安裝完成使用:import&n
python下redis安裝
用python操作redis數(shù)據(jù)庫,先下載redis-py模塊下載地址https://github.com/andymccurdy/redis-py
shell# wget https://github.com/andymccurdy/redis-py
然后解壓
在解壓目錄運行 python setup.py install安裝模塊即可
安裝完成
使用:
import redis r = redis.Redis(host=’localhost’, port=6379, db=0) r['test'] = ‘test’ #或者可以r.set(‘test’, ‘test’) 設(shè)置key r.get(‘test’) #獲取test的值 r.DELETE(‘test’) #刪除這個key r.flushdb() #清空數(shù)據(jù)庫 r.keys() #列出所有key r.exists(‘test’) #檢測這個key是否存在 r.dbsize() #數(shù)據(jù)庫中多少個條數(shù)
更多關(guān)于python中redis的安裝和使用請關(guān)注PHP中文網(wǎng)(www.miracleart.cn)其他文章!