m3z*_*m3z 1 python google-app-engine
我正在使用python 2.6.5开发谷歌应用程序引擎的应用程序 - 我不太熟悉python,但我正在学习.
我试图将一个网址放入一个字符串,所以变量="字符串http://domain.name "
然后我打印出来的字符串.问题是,如果冒号(在http之后)在字符串中,我没有得到任何输出,我不知道为什么.
我试过逃避字符串:
他们似乎没有工作,我不知道还有什么可以尝试
背景是这样的
variables.py是:
...
HOST_URL = "http://domain.name"
...
Run Code Online (Sandbox Code Playgroud)
示例logout.py
import variables
import sys
...
class Logout(webapp.RequestHandler):
""" RequestHandler for when a user wishes to logout from the system."""
def post(self):
self.get()
def get(self):
print(variables.HOST_URL)
print('hi')
self.redirect(variables.HOST_URL)
sys.exit()
Run Code Online (Sandbox Code Playgroud)
要么
在文件functions.py中
import variables
import sys
...
def sendhome(requesthandler)
print 'go to '+variables.HOST_URL
requesthandler.redirect(variables.HOST_URL)
sys.exit()
Run Code Online (Sandbox Code Playgroud)
从上下文调用:
from functions import sendhome
...
class Logout(webapp.RequestHandler):
""" RequestHandler for when a user wishes to logout from the system."""
def post(self):
self.get()
def get(self):
sendhome(self)
Run Code Online (Sandbox Code Playgroud)
任何帮助,将不胜感激
谢谢
如果我没有被误解,GAE使用WSGI,你不是简单地打印东西,你应该返回一个正确的HTTP响应对象(它不是PHP).
我想如果您使用firefox + firebug访问该页面并查看network-> header,您将看到浏览器将http:作为HTTP标头,其值为"//domain.name".
编辑:顺便说一下,你不应该使用"self.response.out.write"而不是"print"吗?
| 归档时间: |
|
| 查看次数: |
1525 次 |
| 最近记录: |