Python Tutorial 18 --- "Writing And Appending To A File"
Python Tutorial 18 --- "Writing And Appending To A File" This PROGRAM or TUTORIAL is about "Writing And Appending To A File" DOC: We have already discussed how to open and read a file in Python, in the last tutorial. If you haven’t read the blog, please go and see that one first. Now we will discuss how to write or insert text to a file and also how we can simultaneously read and write a file. Now, as we know, there are different modes of opening a file, we will cover three of them in this tutorial. Note: f is an object for the file. It is not a method or a special character. You will notice me using f.write() or f.read() or f.close(), in further description or tutorial, but you can use character or word of your own choice instead. MODES PURPOSE “w” mode: Here “w” stands for write. After opening or creating a file, a function, f.write() is used to insert text into the file. The text is written inside closed parenthesis surrounded by double quotations. There is a ...