Saving Consol outputs in a python script
Stephen Hansen
me+python at ixokai.io
Tue May 3 11:43:59 EDT 2016
On Tue, May 3, 2016, at 05:14 AM, drewes.mil at gmail.com wrote:
> What I need are the 2 values for the 2 classes saved in a variable in the
> .py script, so that I can write them into a text file.
>
> Would be super nice if someone could help me!
You shouldn't use the call() convienence function, but instead create a
process using the Popen constructor, passing PIPE to stdout. Then use
communicate() to get the output.
This should get you started:
process = subprocess.Popen(["commandline"], stdout=subprocess.PIPE)
output, error = process.communicate()
Output will be a string, string has a splitlines method, etc.
--
Stephen Hansen
m e @ i x o k a i . i o
More information about the Python-list
mailing list