最简单的方法是使用class subprocess.Popen(command,shell=True)。Popen类有Popen.stdin,Popen.stdout,Popen.stderr三个有用的属性,可以实现与子进程的通信。 将调用shell的结果赋值给python变量 handle = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE) 实例: handle = subprocess.Popen('ls -l', ...