File I/O#

So far we have focused on using terminal outputs (using print()) and inputs (using input()). File I/O, or rather file input/output, is simply reading inputs from and writing outputs to files stored on disc.

In this chapter we will cover the standard library approach. In practice, many modules/packages (such as NumPy) contain their own methods for reading and writing files that are more practical to use in certain contexts.