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

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