[Solved] Redirect the output of python script into a text file [duplicate]


Just use standard shell redirection:

python your_script.py > output_file.ext

If you want to write to a file directly from the script without redirecting:

with open("output.ext", "w") as stream:
    print >>stream, "text"

3

solved Redirect the output of python script into a text file [duplicate]