首页 > 编程技术 > python

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

发布时间:2020-5-6 14:16

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

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()

以上这篇python Popen 获取输出,等待运行完成示例就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持猪先飞。

标签:[!--infotagslink--]

您可能感兴趣的文章: