File Handling with Python || Python programming tutorial
In File Handling, we will be working on a file in our computer and doing various operations on it. Check out my previous blog on Python programming if you want to learn from scratch. Let us say we have a file name poem.txt and we need to perform various operations on that file. Reading the whole file and printing it First, we need to open that text file in our python program using a function open(). The open() function will take two arguments filename and set our intentions. Now, you must be wondering about the second argument i.e. we need to specify our purpose of using that file Read, Write and Append Above all operations can be specified by with different alphabets: Read - 'r' Write - 'w' Append - 'a' Now we will implement programs with this knowledge Program - f = open("poem.txt", "r") f.read() Counting Number of Lines in our file We will divide this process into various steps : To read a single line of a file we can use readlin...