📅  最后修改于: 2022-03-11 14:46:34.090000             🧑  作者: Mango
Capture output of os.system in python
Using popen:
import os
os.popen('cat /etc/services').read()
OR
import subprocess
proc = subprocess.Popen(["cat", "/etc/services"], stdout=subprocess.PIPE, shell=True)
(out, err) = proc.communicate()
print "program output:", out