Note that, /dev/tty is the synonym of the terminal run at current time.
There are usually 3 demands:
when I execute a python script
python script.py
1.output the result to the file script.log
python script.py |tee script.log
Then the output in screen is unchanged, but additionally be copied to the script.log as well.
2:output the both standard output and error to the file script.log with screen output unchanged.
python class.py 2>&1 | tee script.log
3:only pip the output into script.log, without show on the screen.
python class.py 2>&1 | tee >script.log
or
python class.py | tee >script.log