os
ModuleThe os
module in Python provides a way of using operating system dependent functionality. It allows you to interact with the operating system, such as reading or writing to the file system, getting environment variables, and running commands.
os.getcwd()
: Get the current working directory.os.chdir(path)
: Change the current working directory.os.listdir(path='.')
: Return a list of files and directories in the specified path.os.mkdir(path)
: Create a directory.os.makedirs(path)
: Create a directory and any necessary parent directories.os.remove(path)
: Remove a file.os.rmdir(path)
: Remove an empty directory.os.removedirs(path)
: Remove directories recursively.os.rename(src, dst)
: Rename a file or directory.os.path.join(path, *paths)
: Join path components intelligently.os.path.exists(path)
: Check if a path exists.os.path.isfile(path)
: Check if a path is a file.os.path.isdir(path)
: Check if a path is a directory.