python的subprosess模块比os模块更加强大,查了一些资料它的出现就是为了替换老旧的os模块的,以后要多学习一些subprocess模块的东西,最近在学习网络变成,用到了subprocess的一些用法,现在总结一些,以后有新加的都添加都这里面
import subprocess
res=subprocess.Popen("dir",
                     shell=True,
                     stderr=subprocess.PIPE,
                     stdout=subprocess.PIPE)
print(res.stdout.read().decode("gbk"))
原文:https://www.cnblogs.com/zhuhaofeng/p/9584942.html