[英]Run python in background from other python program and continue
How to run a python program in between another python program如何在另一个 python 程序之间运行 python 程序
os.system(r'pythonw.exe D:\text.py')
I have tried this but it had pause execution between the main program and also tried我已经尝试过了,但是它在主程序之间暂停执行并且也尝试过
subprocess.run(r'pythonw.exe D:\text.py')
suppose I have program text.py which notify me every hour I have main program ie假设我有程序 text.py 每小时通知我一次我有主程序,即
code...
os.system(r'pythonw.exe D:\text.py')
code...
print("hello world")
my command should run text.py in the background and execute the following code.我的命令应该在后台运行 text.py 并执行以下代码。
You can use Python Library named "Soldier".您可以使用名为“Soldier”的 Python 库。 This is very easy to use and implement.这非常易于使用和实施。 https://pypi.org/project/soldier https://pypi.org/project/soldier
import soldier
firefox_process = soldier.run('firefox', background=True)
firefox_process.pid
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.