小编Rob*_*rtB的帖子

为什么'tornado.ioloop.IOLoop.instance().start()'给我一个错误?

我是龙卷风的新手.我构建了这个非常基本的龙卷风请求处理程序,我希望在GET上返回"Hello World":

import tornado
import tornado.web

class HelloWorldHandler(tornado.web.RequestHandler):
    @tornado.web.asynchronous 
    def get(self, *args):
        self.write("Hello World")
        self.finish() 

if __name__=="__main__":
    app = tornado.web.Application([
        (r'/help', HelloWorldHandler),
    ], cookie_secret="__SHH_DONT_TELL__")

    app.listen(5001)
    tornado.ioloop.IOLoop.instance().start()
Run Code Online (Sandbox Code Playgroud)

但当我运行它时,我得到:

Traceback (most recent call last):

  File "<ipython-input-1-4bf86d0b596e>", line 1, in <module>
    runfile('D:/Python/notebooks/my_tornado/temp.py', wdir='D:/Python/notebooks/my_tornado')

  File "C:\WinPython-64bit-3.5.2.3\python-3.5.2.amd64\lib\site-packages\spyder\utils\site\sitecustomize.py", line 866, in runfile
    execfile(filename, namespace)

  File "C:\WinPython-64bit-3.5.2.3\python-3.5.2.amd64\lib\site-packages\spyder\utils\site\sitecustomize.py", line 102, in execfile
    exec(compile(f.read(), filename, 'exec'), namespace)

  File "D:/Python/notebooks/my_tornado/temp.py", line 23, in <module>
    tornado.ioloop.IOLoop.instance().start()

  File "C:\WinPython-64bit-3.5.2.3\python-3.5.2.amd64\lib\site-packages\zmq\eventloop\ioloop.py", line 162, in start
    super(ZMQIOLoop, self).start()

  File "C:\WinPython-64bit-3.5.2.3\python-3.5.2.amd64\lib\site-packages\tornado\ioloop.py", line 752, in start
    raise …
Run Code Online (Sandbox Code Playgroud)

python tornado python-3.x

5
推荐指数
1
解决办法
1363
查看次数

标签 统计

python ×1

python-3.x ×1

tornado ×1