在网上看到了mircoblog的这个web程序,用flask框架写的,自己就在windows的环境下实现了下。

1.这个博客系统用到了一个flask插件叫flask_Login 里面涉及到编码解码的问题 出错的提示是:

base = unicode("%s|%s" % (request.remote_addr,request.headers.get("User-Agent")), 'utf8', errors='replace')

TypeError: decoding Unicode is not supported

查阅了下stackoverflow http://stackoverflow.com/questions/7634715/python-decoding-unicode-is-not-supported

原因写的很清楚,可能是"%s|%s" % (request.remote_addr,request.headers.get("User-Agent")),本身已经是unicode了,没必要用utf-8进行解码

这个unicode的意思相当于 参数1.decode('utf-8') 得到的应该是unicode 但是若参数1本身已经是unicode的话 就没必要解码了。

解决方法就是

 

base = "%s|%s" % (request.remote_addr,request.headers.get("User-Agent"))

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-05-05
  • 2021-11-15
  • 2021-12-31
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-05-10
  • 2019-12-24
  • 2021-08-18
  • 2021-08-01
  • 2021-07-09
  • 2022-12-23
相关资源
相似解决方案