Python provides two mechanisms for handling files: the traditional open and close functions that work similarly to other languages, and the "width" context manager. This is particularly convenient as it closes your files for you, even in the case that errors occur. So should you still bother learning how to open and close your files in the traditional way? My two cents. Check out the notebooks linked below for more information on file handling in Python.
Embedded video, part of the following courses:
Computer Programming at Queen Mary, University of London
Jupyter notebook: https://tinyurl.com/yc2tpdfs
Coding for Scientists at Queen Mary, University of London
Jupyter notebook: https://tinyurl.com/bdef2fcj
Notebooks will open on Google Colab - no installation required