#Redis# python 連接redis

Python 要使用 redis,需要先安裝 redis 模塊:

1、安裝redis庫

pip3 install redis

2、測試是否安裝成功:

(base) chenjd:~ xqdd$ python

Python 3.7.1 (default, Dec 14 2018, 13:28:58)

[Clang 4.0.1 (tags/RELEASE_401/final)] :: Anaconda, Inc. on darwin

Type "help", "copyright", "credits" or "license" for more information.

>>>

>>> import redis

>>> r = redis.StrictRedis(host='127.0.0.1',port=6379, db=0)

>>> r.set('hello','World!')

True

>>> r.get('hello')

b'World!'

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章