I skipped a few days and went ahead to look at writing and reading files
Day 21 of my #100DaysOfCode #python challenge I skipped a couple of days in the course because for me it's all about learning new things about code. I think I already know how the thinking process should work. Today I looked ta files opening and writing.
— Wouter Kursten (@Magneet_nl) January 24, 2021
notes
opening files using with will make it close automatically so you don't need to close it dir = "d:\\GIT\\100-days-of-python\\Day 24\\" #don't forget the extra \ to scape the \ with open(f"{dir}text.txt", mode="a") as file: # mode default is read only w is for write (overwrite a for append) file.write("\nfdfddffsdfdsfsdfsd\n") with open(f"{dir}text.txt") as file: contents = file.read() print(contents) if a file doesn't exists it will be craeted