#redis内自维护线程池,过期就断掉链接,所以不需要手动关闭链接
import redis
r = redis.StrictRedis(host='host.com', port=6379) start_dt = str(r.hget('key_v2', 'start_dt'), encoding="utf-8") end_dt = str(r.hget('key_v2', 'end_dt'), encoding="utf-8") print('start_dt=%s,end_dt=%s' % (start_dt, end_dt))