-2
如何獲得這些變量。 這可能很容易,但我今天不認爲。變量訪問,獲取和發佈
class Contact(webapp.RequestHandler):
def get(self):
self.a = random.randint(1,4)
self.b = random.randint(0,4)
template_values = {
'a': self.a,
'b': self.b
}
path = os.path.join(os.path.dirname(__file__), 'contact.html')
self.response.out.write(template.render(path, template_values))
def post(self):
self.response.out.write(self.a)
self.response.out.write(self.b)
引用:
Traceback (most recent call last):
File "C:\Program Files\Google\google_appengine\google\appengine\ext\webapp\__init__.py", line 702, in __call__
handler.post(*groups)
File "D:\My Dropbox\project\main.py", line 133, in post
self.response.out.write(self.a)
AttributeError: 'Contact' object has no attribute 'a'
錯誤發生在哪裏?在'後'?你在這裏試圖做什麼? –
是的在後,簡單的數學驗證碼 –
我們喜歡看到完整的回溯。 –