我正在将python 2.7.6
与falconweb框架一起使用,并尝试运行简单的helloworld程序。但是在运行这个示例时,它给出了以下错误。你知道吗?在
代码:
import falcon
class ThingsResource(object):
def on_get(self, req, resp):
"""Handles GET requests"""
resp.status = falcon.HTTP_200
resp.body = 'Hello world!'
# falcon.API instances are callable WSGI apps
wsgi_app = api = falcon.API()
# Resources are represented by long-lived class instances
things = ThingsResource()
# things will handle all requests to the '/things' URL path
api.add_route('/hello', things)
错误:
^{pr2}$
你的python文件是猎鹰.py因此,当您调用
falcon.API()
时,您在文件中调用了一个方法API()
,而不是从真正的falcon模块调用的。在只要重命名你的文件,它就会工作。在
有关更完整的解决方案,请参见:
Trying to import module with the same name as a built-in module causes an import error:
相关问题 更多 >
编程相关推荐