首页 > 解决方案 > 如何在 python 2.7 中重新启动 python?

问题描述

这是代码:

def restartSim():
        """Restarts the current program.
        Note: this function does not return. Any cleanup action (like
        saving data) must be done before calling this function."""
        python = sys.executable
        os.execl(python, python, * sys.argv)

这段代码在 python 3.6 但在 python 2.7 中可以正常工作。

如何在 python 2.7 中重新启动?

标签: python-2.7restart

解决方案


推荐阅读