Save .txt File In Python
lightningrock

How do you save a .text file in python?

I add content and it works well but when I refresh it all the content disappears! So how do you get the file to save? Is there are way to do it using only repl.it or do you have to use something else and how? Also, I am using python. I also know JavaScript but I just started learning 1 week ago so I am a really bad at it.

You are viewing a single comment. View All
Answered by DynamicSquid [earned 5 cycles]
View Answer
Muffinlavania

i can help..

lightningrock
Muffinlavania

@lightningrock this works
f = open('file.txt','a')
f.write("BOOGA BOOGA")
f.close()
Just make the file.txt beforehand, i reloaded and it saved

Muffinlavania

@Muffinlavania of course wait for repl to save the stuff, then reload

Muffinlavania

@lightningrock
https://repl.it/@Muffinlavania/LustrousInconsequentialPlans
The project with file.txt, you will see it has saved and is in there

lightningrock

wait now it works!

Yay!

@Muffinlavania

Muffinlavania

@lightningrock yay gg POG champ