module
file
Implements the file based methods.
These are Mojo built-ins, so you don't need to import them.
For example, here's how to read a file:
var f = open("my_file.txt", "r")
print(f.read())
f.close()
Or use a with
statement to close the file automatically:
with open("my_file.txt", "r") as f:
print(f.read())
Structs
-
FileHandle
: File handle to an opened file.
Functions
-
open
: Opens the file specified by path using the mode provided, returning a FileHandle.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!
If you'd like to share more information, please report an issue on GitHub
😔 What went wrong?