1.os模块
import os
os.system(commad)
返回0或1,0代表正常;1代表异常
2.os.popen()方法不仅执行命令而且返回执行后的信息对象(常用于需要获取执行命令后的返回信息),是通过一个管道文件将结果返回。
import os
os.popen()
3.subprocess模块
from subprocess import Popen
resultsCommond = Popen(rm_command,stdout=PIPE,
stderr=PIPE,stdin=PIPE,shell=True)
shell:如果该参数为 True,将通过操作系统的 shell 执行指定的命令。
获取标准输出:data = resultsCommond.stdout.read()
获取错误输出:data = resultsCommond.stderr.read()