I'm executing a .py file, which spits out a give string. This command works fine
execfile ('file.py')
But I want the output (in addition to it being shown in the shell) written into a text file.
I tried this, but it's not working :(
execfile ('file.py') > ('output.txt')
All I get is this:
tugsjs6555
False
I guess "False" is referring to the output file not being successfully written :(
Thanks for your help
The simplest way to run a script and get the output to a text file is by typing the below in the terminal:



PCname:~/Path/WorkFolderName$ python scriptname.py>output.txt



*Make sure you have created output.txt in the work folder before executing the command.
How to execute a python script and write output to txt file?