这是我的代码:
import webapp2
class Index(webapp2.RequestHandler):
def get_cookie(self, name, notfound=""):
return self.request.cookies.get(name, notfound)
def get(self):
self.response.headers['Content-Type'] = 'text/plain'
self.response.headers.add_header('Set-Cookie', "Foo=Hello World!")
self.response.headers.add_header('Set-Cookie', "Bar=With, Commas")
txt1 = self.get_cookie("Foo", "Foo cookie not found!")
txt2 = self.get_cookie("Bar", "Bar cookie not found!")
self.response.out.write(txt1 + " " + txt2)
app = webapp2.WSGIApplication([('/', Index)], debug=True)
代码会输出,但是输出有问题...
浏览器甚至不转义空格......我应该怎么做才能正确显示 cookie 值?