Ale*_*lex 1 python unicode utf-8 redis
我是redis的新手,我想知道redis-py是否支持unicode和utf-8. 我想我们也可以编码和解码,但我不知道如何. 假设我在redis中输入一个值:'ü'. 然后我会得到这个输出:'\ xc3\xbc'
有人可以解释我这个过程
谢谢
Ste*_*tin 5
Redis(数据存储区)存储字节,而不是unicode.
在Python redis的模块,构造redis.Redis和redis.StrictRedis有一个encoding参数,默认为utf-8.
redis.Redis
redis.StrictRedis
encoding
utf-8
所以你的'ü'在用redis存储之前用utf-8编码.当您稍后在python中检索它时,您只需获取编码的字节.
>>> print(b'\xc3\xbc'.decode('utf-8')) ü
归档时间:
9 年,6 月 前
查看次数:
1561 次
最近记录: