How do i read and write files without using the close function in python?
-
Also see:
https://www.lightnetics.com/post/9894
https://www.lightnetics.com/post/9895There two keywords with and as that can be used to write and read from files. You can see from the code there's no close function.
with open("cakestobuy.txt", "w") as w_cakefile: w_cakefile.write("This is a new trial cake 2") with open("cakestobuy.txt", "r") as r_cakefile: print(str(r_cakefile.read()))
© Lightnetics 2024