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
精彩评论