繁体   English   中英

Python 3.5 os.execl在Windows 10上无法正常运行

[英]Python 3.5 os.execl not working as it should on Windows 10

我想从内部重新启动python脚本。 所以我写了一个小的测试脚本:

def restart_program():

    print ("Restarting")
    python = sys.executable
    os.execl(python, python, * sys.argv)

if __name__ == "__main__":

if answer.lower().strip() in "y yes".split():
    restart_program()

因此,从理论上讲,我想将不确定的“重新启动”打印在控制台中。 这确实发生了-Windows 10上的Python 3.5除外。

Windows 10上切换至Python 3.5时-很烂。 我需要按两次Enter键才能获得下一个“重新启动”。 而且在更复杂的脚本中它崩溃了。

我也尝试过MacOS-Python 2.7Python 3.5上都可以正常工作

有人可以建议在Windows 10上执行此操作的正确方法吗?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM