Ask coding questions

← Back to all posts
python open and read file with repl.it
AbdelghaniTahar

how to open and read file with repl.it on line

Voters
JikanTribal
AnineStener
AbdelghaniTahar
Comments
hotnewtop
HappyFakeboulde

Add a file in the editor
Give it a name
In your program put f = open(filename, "r") where filename is the name of the file you created
To read from the file put t = f.read() where t is the name of the variable to save it in
Remember to close the file object with f.close()

Hwiggy