开发者

console output of os.system()?

开发者 https://www.devze.com 2023-03-22 09:01 出处:网络
When calling os.system() in the Interactive Interpreter, you can see what it output\'s in the console.

When calling os.system() in the Interactive Interpreter, you can see what it output's in the console. But in my case, I needed to change sys.stderr开发者_C百科 and sys.stdout to an instance of another class and the os.system function is called within an exec statement. The problem is, I don't see what it output's. It does not write to stderr nor to stdout. So my question: Where does the printed output of os.system() go to ?

Thanks, Niklas


It goes to either file descriptor 1 or 2, depending on whether it outputs to stdout or stderr. If you need finer control of the output then you should use subprocess.

0

精彩评论

暂无评论...
验证码 换一张
取 消