首页 > 编程语言 > 详细

python 安装 redis

时间:2019-08-22 18:55:17      阅读:101      评论:0      收藏:0      [点我收藏+]

 

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

python 安装 redis

原文:https://www.cnblogs.com/ericblog1992/p/11395923.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!