import  redis
import chardet

r.set("name","我是在Py3保存的中文字符串")
ret = r.get("name")#(一个汉字三个字节)
print(ret,type(ret))
print(chardet.detect(ret))#chardet.detect检测的字符串越长越准确,越短越不准确。
print(ret.decode("utf-8"))

在解码Redis返回的字符前要先检测编码方式,根据检测出的编码方式来编码。

chardet.detect检测的字符串越长越准确,越短越不准确

查看于:http://blog.csdn.net/xiemanr/article/details/72793081

相关文章:

  • 2021-11-28
  • 2022-12-23
  • 2021-07-26
  • 2021-06-04
  • 2022-01-12
  • 2022-12-23
  • 2021-07-07
  • 2021-08-25
猜你喜欢
  • 2022-01-09
  • 2021-05-26
  • 2021-11-02
  • 2021-05-18
  • 2022-02-20
  • 2021-09-21
  • 2021-05-20
相关资源
相似解决方案