Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/338.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 类和Google应用程序引擎_Python_Google App Engine - Fatal编程技术网

Python 类和Google应用程序引擎

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!' 什么是解决方案,

我正在谷歌应用程序引擎中试用简单的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!'

什么是解决方案,使这项工作

试试这样的方法:

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):