开发者

get console output

how can i receive the console output of any python file (error开发者_开发百科s, everything printed using the print() command)?

example: main.py starts test.py and gets its output


You can use sys.stderr from the sys module. print() uses sys.stdout by default.

import sys

# Print to standard output stream
print("Normal output...")

# Print to standard error stream
print("Error output...", file=sys.stderr)


i dont know if this will help but im sure it will give you an idea. in vb.net or c#.net we capture console stream using the process StandardOutput like this:

Dim p as Process = Process.Start("cmd")
p.WaitForExit(Integer.MaxValue)
dim output as String = p.StandardOutput
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜