第一种情况
os.system('ps aux')
执行系统命令,没有返回值
第二种情况
result = os.popen('ps aux')
res = result.read()
for line in res.splitlines():
print line
p = subprocess.Popen('ps aux',shell=True,stdout=subprocess.PIPE)
out,err = p.communicate()
for line in out.splitlines():
print line
第三种情况
output = commands.getstatusoutput('ps aux')
print output