When running python script in linux, we may want to save all python print() output into a text file. In this tutorial, we will introduce you how to do.
How to save python print() into a text file?
There are some methods to do it.
Method 1: Using linux script command
Here is the tutorial:
Save Python Print Message into File When Training Model on Linux – Deep Learning Tutorial
Method 2: Using python logging library
Here is the tutorial:
Save Python Message into a Log File with logging – Deep Learning Tutorial
Method 3: Using linux nohup command
For example:
nohup python rnn_train_8k.py >> out.log 2>&1 &
In this example, we will save all python print into text file: out.log