If you just want to read or write a file see open(), if you want to manipulate paths, see the os.path module, and if you want to read all the lines in all the files on the command line see the fileinput module
The design of all built-in operating system dependent modules of Python is such that as long as the same functionality is available, it uses the same interface
All functions accepting path or file names accept both bytes and string objects, and result in an object of the same type, if a path or file name is returned
API related to processes (e.g. fork(), execve()), signals (e.g. kill(), wait()), and resources (e.g. nice()) are not available on WebAssembly platforms
All functions in this module raise OSError (or subclasses thereof) in the case of invalid or inaccessible file names and paths, or other arguments that have the correct type, but are not accepted by the operating system
File Names, Command Line Arguments, and Environment Variables
In Python, file names, command line arguments, and environment variables are represented using the string type. On some systems, decoding these strings to and from bytes is necessary before passing them to the operating system
Python uses the filesystem encoding and error handler to perform the conversion between strings and bytes for file names, command line arguments, and environment variables
The filesystem encoding must guarantee to successfully decode all bytes below 128. If the filesystem encoding fails to provide this guarantee, API functions can raise UnicodeError
Changes to the environment made after the os module is imported are not reflected in os.environ, except for changes made by modifying os.environ directly