每次运行新模块时都会重新启动Python shell

发布于 2024-09-27 11:27:32 字数 353 浏览 2 评论 0原文

我在 Windows XP 中使用 Python 3.1,当我尝试同时使用多个模块时,Python shell 会重新启动。我能做些什么?

这是我的模块 benutzer.py:

class Benutzer(object):
    def __init__(self,benutzer):
        self.name =  benutzer
        self.email = None

    def setzeEmail(self, adresse):
        self.email = adresse

当我在 IDLE 中执行“运行模块”时,shell 会显示“重新启动”。

I use Python 3.1 inside Windows XP and when I try to use more than one module at the same time, the Python shell restarts. What can I do?

This is my module benutzer.py:

class Benutzer(object):
    def __init__(self,benutzer):
        self.name =  benutzer
        self.email = None

    def setzeEmail(self, adresse):
        self.email = adresse

When I do "Run Module" inside IDLE, the shell says RESTART.

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

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

发布评论

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

评论(2

猛虎独行 2024-10-04 11:27:32

IDLE 会重新启动 Python 以确保模块正确重新加载,因为这有时会出现问题。这是正常现象,无需担心;对于模块的其他用途,不会发生这种情况。

IDLE restarts Python to make sure your module gets reloaded properly, because this can sometimes be problematic. This is normal and nothing to be concerned about; it won't happen for other uses of your module.

哆啦不做梦 2024-10-04 11:27:32

我们可以采取一些措施来解决这个问题。您可以通过 exec(open("other_script.py").read()) 加载它们,而不是通过按 F5 或单击运行来运行模块,如下所述:如何防止 python IDLE 在运行新脚本时重新启动

There is something that can be done about it. Rather than running your modules by hitting F5 or clicking run you can load them via exec(open("other_script.py").read()) as explained here: How to prevent python IDLE from restarting when running new script

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