How to open a file?

How to open a file
Repl link:

code snippet

You can open a file by clicking on it.

I suppose you are using python

you can use open() to open a file

it’s a long story if you want to truely understand this function so better google it :slight_smile:


If you want to open a file, there are multiple ways:

  • On the File sidebar, press your desired file
  • Press “New Tab” in the workspace, then type the name of your desired file

In your Python code, you could do:

my_writable_file = open("myfile.txt","w") # the w means only writable
my_writable_file.write("myfile.txt's contents!") # the .write replaces the file's contents or creates a new file with the content
my_readable_file = open("myfile.txt","r") # the r means only readable
print( # the .read looks at the file's content.

Hope this helps!


To open a file, click on the file name in the side bar (right side). Or if you want to open the file in Python, paste this code

with open("filename.txt") as f:
   #code here...

What is the use for the “my…file” is it important or are you just assigning a variable to it?

I’m just assigning a variable.

1 Like