简体   繁体   English

在新的终端窗口上打开并执行python脚本

[英]Opening and executing python scripts on new terminal windows

I want to, from a python script, open a new terminal window. 我想从python脚本中打开一个新的终端窗口。 Then, on that new window, run another python script, located on the same directory. 然后,在该新窗口上,运行位于同一目录中的另一个python脚本。 I needs to be on another window, because both scripts have while True loops, and I need them to run simultaneously. 我需要在另一个窗口上,因为两个脚本都具有while True循环,并且我需要它们同时运行。 How would I do that? 我该怎么做? Thanks everyone! 感谢大家!

You can just spawn an xterm with the python code used: 您可以使用所用的python代码生成xterm:

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

This will close when the process ends. 该过程结束时将关闭。

If you need to, you can do this from inside a python script using the subprocess module ( https://docs.python.org/2/library/subprocess.html ). 如果需要,您可以使用subprocess模块​​( https://docs.python.org/2/library/subprocess.html )从python脚本内部执行此操作。

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

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