E
E
enabl32018-11-01 09:06:13
Python
enabl3, 2018-11-01 09:06:13

Outputting Python script errors to a file?

Hello everyone, most likely the question is initially stupid, but I can not figure it out.
How to redirect everything that it outputs (errors, etc.) to a file when running a script?
The easiest way python test.py > log.txt doesn't work.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vladimir, 2018-11-01
@enabl3

forget about print commands for a while and try to use the standard logging module . I think it will make your life much easier in the future.

J
jcmvbkbc, 2018-11-01
@jcmvbkbc

redirect whatever it outputs

python test.py >& log.txt

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question