f = open("demofile3.txt", "w")
f.writelines(["\nSee you soon!", "\nOver and out."])
f.close()
`
I have been trying to create or open a file and write something in it but it does not seem to do anything.
f = open("demofile3.txt", "w")
f.writelines(["\nSee you soon!", "\nOver and out."])
f.close()
`
I have been trying to create or open a file and write something in it but it does not seem to do anything.
it's about pwd.
But here is a method: use full path.
For example:
from pathlib import Path
folder = Path(__file__).parent
your_txt = folder / "demofile3.txt"
with open(your_txt, "w") as f:
f.writelines(["\nSee you soon!", "\nOver and out."])