python执行外部命令并获取输出

使用subprocess库

import subprocess
out_bytes = subprocess.check_output(['netstat','-a'])

out_bytes = subprocess.check_output('grep python j wc > out', shell=True)
原文地址:https://www.cnblogs.com/buxizhizhoum/p/9009813.html