Python 类和Google应用程序引擎
我正在谷歌应用程序引擎中试用简单的Hello World应用程序。我想创建一个单独的类,将其导入main.py并使用 main.py:Python 类和Google应用程序引擎,python,google-app-engine,Python,Google App Engine,我正在谷歌应用程序引擎中试用简单的Hello World应用程序。我想创建一个单独的类,将其导入main.py并使用 main.py: import helloWorld helloWorld.hi() helloWorld.py: class helloWorld(): def hi(): print 'Content-Type: text/plain' print '' print 'Hello, world!' 什么是解决方案,
import helloWorld
helloWorld.hi()
helloWorld.py:
class helloWorld():
def hi():
print 'Content-Type: text/plain'
print ''
print 'Hello, world!'
什么是解决方案,使这项工作 试试这样的方法:
from helloWorld import helloWorld
helloWorld().hi()
或:
第一个只从模块helloWorld
导入类helloWorld
,您可以直接根据其名称使用它
在第二个示例中,我们从模块helloWorld
导入了所有内容,但我们只能使用helloWorld.attr
语法访问它
类helloWorld
的方法hi
必须包含参数self
def hi(self):
我假设这就是他真正想要的:)尽管他的类方法签名是错误的:/谢谢……我认为我的中心问题是yaml文件。由于某些原因,我无法让GAE正确上传我的其他脚本,每当我尝试导入外部类时,它都会给出500个错误…@JumBopap我没有使用GAE,所以对此不能说太多。
def hi(self):