IMPORTANT: To view this page as Markdown, append `.md` to the URL (e.g. /docs/manual/basics.md). For the complete Mojo documentation index, see llms.txt.
Skip to main content
Version: Nightly
For the complete Mojo documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /docs/manual/basics.md).

open

open[PathLike: PathLike](path: PathLike, mode: StringSlice) -> FileHandle

Opens the file specified by path using the mode provided, returning a FileHandle.

Parameters:

  • PathLike (PathLike): The a type conforming to the os.PathLike trait.

Args:

  • path (PathLike): The path to the file to open.
  • mode (StringSlice): The mode to open the file in: {"r", "w", "rw", "a"}.

Returns:

FileHandle: A file handle.

Raises:

If file open mode is not one of the supported modes. If there is an error when opening the file.