A program that reads or writes files must sometimes interact with the file system in other ways, for example, checking whether or not a file or directory exists, seeing if a file can be read or written to, getting file size or modification time, reading a directory’s contents, and so on.
The primary modules for working with the file system in Python include os, os.path, and pathlib. My preference is pathlib, the newest of the three, because its Path() function returns file path objects that can read, ...