【问题标题】:Opening and executing python scripts on new terminal windows在新的终端窗口上打开和执行 python 脚本
【发布时间】:2014-05-27 22:17:22
【问题描述】:

我想从 python 脚本打开一个新的终端窗口。 然后,在该新窗口中,运行位于同一目录中的另一个 python 脚本。 我需要在另一个窗口上,因为两个脚本都有 while True 循环,我需要它们同时运行。 我该怎么做? 谢谢大家!

【问题讨论】:

  • 目前有示例代码吗?

标签: python macos terminal operating-system


【解决方案1】:

您可以使用所使用的 python 代码生成一个 xterm:

xterm -e "python /path/to/your/file.py"

这将在进程结束时关闭。

如果需要,您可以在 python 脚本中使用 subprocess 模块 (https://docs.python.org/2/library/subprocess.html) 执行此操作。

【讨论】:

    猜你喜欢
    • 2022-12-11
    • 2019-10-26
    • 2020-05-14
    • 2015-07-04
    • 1970-01-01
    • 2013-11-18
    • 2017-07-09
    • 1970-01-01
    • 2018-07-02
    相关资源
    最近更新 更多