+ 1

how to copy the output of the python program to a text file

i am using ultrasonic sensor in raspberry pi. I need to store the values in the output screen of python. is there any program to copy the output to text file

2nd Feb 2018, 1:14 PM
RAMALINGAM R
RAMALINGAM R - avatar
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
2nd Feb 2018, 9:13 PM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
+ 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.
3rd Feb 2018, 5:41 AM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
+ 2
not exactly sure if thats what you mean but here it is: python3 test.py > out.txt
2nd Feb 2018, 1:32 PM
Kuba H
Kuba H - avatar
+ 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
3rd Feb 2018, 3:20 AM
RAMALINGAM R
RAMALINGAM R - avatar
+ 1
i want to save the output python data to a text file
3rd Feb 2018, 3:17 AM
RAMALINGAM R
RAMALINGAM R - avatar