Using python redis database operations, first download redis-py module https: githubcomandymccurdyredis-py in the extract directory to run pythonsetuppyinstal using python redis database operations, first download redis-py module https://github.com/andymccurdy/redis-py
Run the python setup. py install installation module in the extract directory.
Or directly use pip to install
Usage:
Import redis
R = redis. Redis (host = 'localhost', port = 6379, db = 0)
R ['test'] = 'test' # or you can set the key in r. set ('test', 'test ').
R. get ('test') # obtain the value of test
R. delete ('test') # delete this key
R. flushdb () # clear the database
R. keys () # List all keys
R. exists ('test') # check whether this key exists
R. dbsize () # Number of items in the database
The above describes how to use redis in python. For more information, see other related articles in the first PHP community!