Mojo module
file
Provides APIs to read and write files.
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!
