如果__name__ ==; __ Main __&quot“:失败;为什么会赢得我的课程,__________________________________________________________

发布于 2025-02-03 09:26:33 字数 1138 浏览 2 评论 0原文

我一直在简化此代码,但我没有言语。简而言之,该文件不会运行以调用存在的类,也不会扩展其中的功能。这个错误是我从未遇到的事情,并且希望有人能提供一些清晰度。

class Server_Design:
    def __init__(self):
        self.intro_input()

    def intro_input(self):
        self.host = input('Host: ')
        self.port = input('Port: ')
        print("y")

if __name__ == "__main__":
    Server_Design()

命令行输出:

    [SpyderKernelApp] ERROR | Exception in message handler:
    Traceback (most recent call last):
      File "C:\Users\ ----\anaconda3\lib\site-packages\spyder_kernels\comms\frontendcomm.py", line 164, in poll_one
        asyncio.run(handler(out_stream, ident, msg))
      File "C:\Users\ ----\anaconda3\lib\site-packages\nest_asyncio.py", line 33, in run
        task = asyncio.ensure_future(main)
      File "C:\Users\ ----\anaconda3\lib\asyncio\tasks.py", line 677, in ensure_future
        raise TypeError('An asyncio.Future, a coroutine or an awaitable is '
    TypeError: An asyncio.Future, a coroutine or an awaitable is required
    [SpyderKernelApp] ERROR | Exception in message handler:
    Traceback (most recent call last):

无限期重复

I have been simplifying this code and I am without words. Simply put, the file will not run to call the classes present, and by extension the functions within. The error is something I have never come across and would like some clarity on, if someone could provide it, please.

class Server_Design:
    def __init__(self):
        self.intro_input()

    def intro_input(self):
        self.host = input('Host: ')
        self.port = input('Port: ')
        print("y")

if __name__ == "__main__":
    Server_Design()

COMMAND LINE OUTPUT:

    [SpyderKernelApp] ERROR | Exception in message handler:
    Traceback (most recent call last):
      File "C:\Users\ ----\anaconda3\lib\site-packages\spyder_kernels\comms\frontendcomm.py", line 164, in poll_one
        asyncio.run(handler(out_stream, ident, msg))
      File "C:\Users\ ----\anaconda3\lib\site-packages\nest_asyncio.py", line 33, in run
        task = asyncio.ensure_future(main)
      File "C:\Users\ ----\anaconda3\lib\asyncio\tasks.py", line 677, in ensure_future
        raise TypeError('An asyncio.Future, a coroutine or an awaitable is '
    TypeError: An asyncio.Future, a coroutine or an awaitable is required
    [SpyderKernelApp] ERROR | Exception in message handler:
    Traceback (most recent call last):

repeating indefinitely

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

以酷 2025-02-10 09:26:33

Spyder 5.2.0 (于2021年11月发布)中固定了此误差。请按照发布的说明在这里

This error was fixed in Spyder 5.2.0 (released on November 2021). Please update to a more recent version by following the instructions posted here.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文