当前位置:主页 > 软件编程 > Python代码 >

python Popen 获取输出,等待运行完成示例

时间:2021-07-07 08:51:33 | 栏目:Python代码 | 点击:

我就废话不多说了,直接上代码吧!

import subprocess

def excuteCommand(com):
 ex = subprocess.Popen(com, stdout=subprocess.PIPE, shell=True)
 out, err = ex.communicate()
 status = ex.wait()
 print("cmd in:", com)
 print("cmd out: ", out.decode())
 return out.decode()

您可能感兴趣的文章:

相关文章