首页 > 代码库 > python3存入redis是bytes

python3存入redis是bytes

在python3 中使用redis存储数据,存进去的是bytes

>>> import redis
>>> import time
>>> import json

>>> pool = redis.ConnectionPool(host=localhost, port=6379)
>>> redis_obj = redis.Redis(connection_pool=pool)

>>> redis_obj.set(key2,str_data)
True
>>> redis_obj.get(key2)
bhello
>>> redis_obj.rpush(my_test_list_key2,json.dumps([{k1:v1},time.time()]))
1
>>> get_data_from_redis_key = redis_obj.lrange(my_test_list_key2,-1,-1)[0]
>>> type(get_data_from_redis_key)
<class bytes>

 

python3存入redis是bytes