相关疑难解决方法(0)

Python:运行os.system后如何获取stdout?

我希望stdout在运行os.system调用后获取变量.

让我们以此行为例:

batcmd="dir"
result = os.system(batcmd)
Run Code Online (Sandbox Code Playgroud)

result将包含错误代码(stderr 0在Windows下或1在某些linux下用于上面的示例).

如何stdout在执行的命令中不使用重定向来获取上述命令?

python os.system stdout stderr python-2.7

79
推荐指数
6
解决办法
16万
查看次数

标签 统计

os.system ×1

python ×1

python-2.7 ×1

stderr ×1

stdout ×1