Logging output from python
Leonhard Vogt
leonhard.vogt at gmx.ch
Sat Dec 9 06:46:31 EST 2006
Cameron Walsh schrieb:
>
> If it's on linux you can just redirect the screen output to a file:
>
> python initialfile.py 1>stdout.txt 2>stderr.txt
> As for windows, I'll test it now...
>
> It turns out you can at least redirect the output to a file, I'm not
> sure what it does with standard error or even if it exists or not.
>
> python initialfile.py > output.txt
>
> should work.
>cmd
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.
>type output.py
import sys
print 'This is print.'
sys.stdout.write('This is stdout.write()\n')
sys.stderr.write('This is stderr.write()\n')
>python output.py 1>stdout.txt 2>stderr.txt
>type stdout.txt
This is print.
This is stdout.write()
>type stderr.txt
This is stderr.write()
Seems on XP it works too.
Leonhard
More information about the Python-list
mailing list