python测试redis是否可以使用

mac2022-06-30  29

前提打开redis服务,windows打开方式到redis的安装目录命令行输入redis-server

from redis import StrictRedis redis = StrictRedis(host='localhost', port=6379,decode_responses=True) redis.set('name', 'Bob') print(redis.get('name'))

  

decode_responses默认值为false获取值类型为byte,改成true即可获取字符串。

转载于:https://www.cnblogs.com/c-x-a/p/8779952.html

最新回复(0)