注意:Python新手。在
想听听真正使用它的专业人士的意见:
在subprocess.Popen()
和{
除非你想知道我为什么在想这个问题,或者你的答案围绕着什么,你现在可以停止阅读了。在
我被启发提出这个问题是因为我正在解决一个脚本中的一个问题,我开始使用subprocess.Popen()
,最后调用了系统暂停,然后想删除创建系统暂停的.exe,但我注意到Popen()
,虽然我尝试添加communicate()
,但所有命令似乎都是一起运行的(在关闭exe之前执行对.exe的删除操作..)。在
下面是我上面描述的伪代码:
subprocess.Popen(r'type pause.exe > c:\worker.exe', shell=True).communicate()
subprocess.Popen(r'c:\worker.exe', shell=True).communicate()
subprocess.Popen(r'del c:\worker.exe', shell=True).communicate()
如果创建
Popen
对象,则必须自己调用sp.wait()
。在如果您使用
call
,那么就完成了。在相关问题 更多 >
编程相关推荐