
1 solowind 2012-05-15 12:05:13 +08:00 习惯在写入和读取的时候都做unicode转码,用Python来保证,例如 def _unicode(s): if isinstance(s, str): try: return s.decode('utf-8') except UnicodeDecodeError: pass return s Redis怎么配置不太清楚,这个代码好像是从Tornado里面找到的 |
2 goofansu OP @solowind 谢谢。数据在数据库中都是unicode的,可是保存到redis中它会自动转成str,再取出就不对了,网上搜了下也没搜出什么结果。 |
3 gonbo 2012-05-15 12:19:41 +08:00 @goofansu redis-py的代码里面是做过encoding到utf-8的。不能encoding才str。你可以文件里面加上 # -*- coding: UTF-8 -*- |
5 maga 2014-07-20 10:55:43 +08:00 ecode_respOnses=True 参数 Looking into the StrictRedis.__init__ there is a parameter decode_responses which by default is False. https://github.com/andymccurdy/redis-py/blob/master/redis/client.py#L284 (line num may change in future, look in __init__). Pass in decode_respOnses=True on construct and for me this FIXES THE OP'S ISSUE. |