cookie的中文是什么,about cookie的中文意思

  cookie的中文是什么,about cookie的中文意思

  set_cookie:cookie值为中文时会出错。

  错误:

  回溯(最近一次呼叫):

  文件/usr/lib/python 3.5/wsgiref/handlers。py ,第138行,运行中

  self.finish_response()

  文件/usr/lib/python 3.5/wsgiref/handlers。py ,第180行,在完成_响应中

  自写(数据)

  文件/usr/lib/python 3.5/wsgiref/handlers。py ,第274行,写

  self.send_headers()

  文件/usr/lib/python 3.5/wsgiref/handlers。py ,第333行,在发送标题中

  自我. write(字节(self.headers))

  文件"/usr/lib/python 3.5/wsgiref/headers。py”,第142行,以__字节_ _

  返回字符串(自身)。编码(“iso-8859-1”)

  unicode encoded error错误:"拉丁语-1 "编解码器无法对位置288处的字符" u90d1 "进行编码:序号不在范围内(256)

  原因:中文不能通过拉丁文-1 编码

  解决:

  设置cookie:

  newuser=username.encode(utf-8 ).解码("拉丁文1")

  response.set_cookie(uname ,newuser)

  如有要求COOKIES.get(uname ):

  上下文[uname]=请求。饼干。编码(“拉丁语-1”).解码(“utf-8”)

cookie的中文是什么,about cookie的中文意思