python 安装 redis

https://pypi.org/project/redis/

pip install redis

import redis
pool = redis.ConnectionPool(
host = "localhost",
port = 6379,
password = '',
db = 0,
max_connections = 20
)

from redis_db import pool
import redis
import time

con = redis.Redis(
connection_pool = pool
)

con.set("country","英国")
con.set("city","伦敦")
# city = con.get("city").decode("utf-8")
con.expire("city",5)
time.sleep(6)
city = con.get("city").decode("utf-8")
print(city)

del con
原文地址:https://www.cnblogs.com/ericblog1992/p/11395923.html