5 Answers
+ 5
Could you please elaborate a bit more? Do you want to have "screenshots" of the program output being dumped to a file? Or just to save a data stored n a variable to the file?
Either way, you might want to use the 'pickle' module, which ellegantly saves even the most complex data types into a file and later seamlessly restores it. Check it out:
https://code.sololearn.com/cNXRdhIOg17U/?ref=app
+ 4
If so, you just have to file.write() it. Just remember to do it in one of the 'append' modes, so that it is not overwritten each time you run the script.
+ 2
not exactly sure if thats what you mean but here it is:
python3 test.py > out.txt
+ 2
for example i am using temperature sensor with python program. It shows the temperature value in each and every second. I want these output to be stored in a text file
+ 1
i want to save the output python data to a text file