Joh*_*ott 4 python
我想要这样的代码:
if True: run('ABC.PY') else: if ScriptRunning('ABC.PY): stop('ABC.PY') run('ABC.PY'):
基本上,我想abc.py根据某些条件运行一个文件,例如。我想停止它,然后从另一个python脚本再次运行它。可能吗?
abc.py
我正在使用Windows。
rok*_*rok 5
您可以使用python Popen对象在子进程中运行进程
这样run('ABC.PY')会p = Popen("python 'ABC.PY'")
run('ABC.PY')
p = Popen("python 'ABC.PY'")
if ScriptRunning('ABC.PY) 将会 if p.poll() == None
if ScriptRunning('ABC.PY)
if p.poll() == None
stop('ABC.PY') 将会 p.kill()
stop('ABC.PY')
p.kill()
归档时间:
6 年,6 月 前
查看次数:
58 次
最近记录: