1. 程式人生 > >Python內置模塊之subprocess

Python內置模塊之subprocess

proc read ESS style div color imp 解碼 ret

import subprocess
ret = subprocess.Popen(netstat -ano,shell=True,stdout=subprocess.PIPE,stderr=subprocess.PIPE)  # PIPE管道
print(ret.stdout.read().decode(gbk)) # 需要解碼
print(ret.stderr.read().decode(gbk)) # 需要解碼

Python內置模塊之subprocess