Save the program run python print output content to txt / log and other documents

First, create a test.py file, as follows:

for i in range(1,21):
    print("the number is {}".format(i))

 Open a terminal, enter test.py folder where the file, run:

python<test.py>test.log

 Then, you can see the folder test.log generate a file, the contents of print output is saved in test.log years.

Guess you like

Origin www.cnblogs.com/DreamRJF/p/11351163.html