stdout of external program.
Jean-Michel Pichavant
jeanmichel at sequans.com
Fri Jul 30 05:00:50 EDT 2010
Paul Lemelle wrote:
> HELP! :)
>
> I am trying to output the following program's output to either a file
> or variable, how can this be done?
>
> # Writing the output to a standard argv argument
>
> #1/usr/bin/python
>
> import sys
>
> for arg in sys.argv:
> print arg
>
> #END
>
> Thanks,
> Paul
>
>
Hi Paul, after reading 4 times your post, I still don't see what you
want to achieve.
What are you calling a variable ? an os variable ?
import sys
file = open('testfile.txt', 'w')
file.write(str(sys.argv))
file.close()
second hit when googling your question:
http://docs.python.org/tutorial/inputoutput.html
JM
More information about the Python-list
mailing list