我有一个在谷歌应用引擎上运行的 pythonprog。该程序向我抛出错误消息:(回溯)
File "/Users/patriknygren82/patriks-hello-udacity/Unit3/blog/main.py", line 36, in get
self.write("Hello test!")
File "/Users/patriknygren82/patriks-hello-udacity/Unit3/blog/main.py", line 25, in write
self.response.out.write(*a, **kw)
NameError: global name 'kw' is not defined
简单的“hello world”程序如下所示:
import webapp2
import jinja2
import os
jinja_environment = jinja2.Environment(
loader=jinja2.FileSystemLoader(
os.path.dirname(__file__) + "/templates"),
autoescape=True)
class BaseHandler(webapp2.RequestHandler):
def write(self, *a, **kv):
self.response.out.write(*a, **kw)
def render_str(self, template, **params):
t=jinja_environment.get_template(template)
return t.render(params)
def render(self, template, **kw):
self.write(self.render_str(template, **kw))
class MainHandler(BaseHandler):
def get(self):
self.write("Hello test!")
app = webapp2.WSGIApplication([('/', MainHandler)], debug=True)
有人能帮帮我吗!谢谢