In this video, I explain different Python file handling mechanisms. I demonstrate in practical way how we can perform file input and output operations. There are two main methods to work with files. One using simple iterative calls to open files and another by using 'with' block in Python.
In this video, I first show how we can read data from a file using open function in Python. This open function takes file name as argument and second argument is the file mode which is "read" by default. I also show a demo of how we can write files as string or from a collection using writelines method.
Finally, I show the use of "with" block to easily work with files. Using this, we do not need to explicitly close the file. It will be closed when the with block ends.
How to read data from a file in Python [0:43]
How to write data in a text file in Python [7:03]
Using with block in Python [12:21]
If you like our content, click on SUBSCRIBE button and click on Bell icon to receive latest and greatest updates of my video lessons.
Follow us on Facebook, Twitter, Instagram
Facebook Link: / techprogrammer1
Twitter Link: / techprogrammer1
Tumblr Blog: https://www.tumblr.com/blog/techprogr...