gpt4 book ai didi

python-3.x - : NotImplementedError发生了异常

转载 作者:行者123 更新时间:2023-12-03 09:03:12 29 4
gpt4 key购买 nike

第一次执行此操作,并在app.listen(port)处获取异常

import tornado.web
import tornado.ioloop

class basicRequestHandler(tornado.web.RequestHandler):
def get(self):
self.write("Hello, World this is a python command executed from the backend.")

if __name__ == "__main__":
app = tornado.web.Application([
(r"/", basicRequestHandler)
])

port = 8882
app.listen(port)#Getting exception here
print(f"Application is ready and listening on port {port}")
tornado.ioloop.IOLoop.current().start()

最佳答案

在python 3.8中:

import tornado.ioloop
import tornado.web
import asyncio

class basicRequestHandler(tornado.web.RequestHandler):
def get(self):
self.write("Hello, World this is a python command executed from the backend.")

if __name__ == "__main__":
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
app = tornado.web.Application([
(r"/", basicRequestHandler)
])
port = 8882
app.listen(port)
print(f"Application is ready and listening on port {port}")
tornado.ioloop.IOLoop.current().start()

关于python-3.x - : NotImplementedError发生了异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61402513/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com