Input and Output (I/O)
So far, we’ve written scripts and executed them from the command line. As a result, all of the output that we’ve created was displayed right under the prompt where we issued the command. That approach is referred to as sending output to the terminal. It’s also possible to send output to either a file or a network location. Similarly, you may also provide input to a program from a file.
Redirecting Standard Input and Output
The easiest way to send output to a file is to redirect it at the command line using the > operator. For example, this command would run the password.py script in Python and save the output in a file named password_output.txt:
python password.py > password_output.txt
When you execute this command, the operating system creates a new file called password_output.txt and sends all of the output that would normally be displayed on the screen to the file instead. If the file already exists, its contents are overwritten...