can we save print msg into a file when script running ?

Peter Otten __peter__ at
Wed Oct 12 16:37:59 CEST 2005

black wrote:

> in my .py file there are a few print to trace out some message and i
> wonder if we can save it into a specified file when that script get
> running. if so, i may just check that file to c how the script is
> running. can anyone show me a right direction ?

If you don't feel comfortable with the command line you can stick

import sys
sys.stdout = open("mylogfile.txt", "w")

at the beginning of your file.


More information about the Python-list mailing list