[ad_1]
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
[ad_2]
solved Redirect the output of python script into a text file [duplicate]