标签:style range lis get list json blog 存储 push
在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‘) b‘hello‘ >>> 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‘>
标签:style range lis get list json blog 存储 push
原文地址:http://www.cnblogs.com/zhming26/p/6306017.html