File Handling in python

“Keep your face always toward the sunshine, and shadows will fall behind you. 🙂 ”

HELLO FRIENDS !!!! Lets have a talk on file handling 🙂

File Handling is the storing of data in a file using a program

Q) What is file handling?                                              

Python file handling and allows users to handle files i.e., to read and write files, along with many other file handling options, to operate on files.

Following mode is supported: 1) r: open an existing file for a read operation.

 2) w: open an existing file for a write operation. If the file already contains some data then it will be overridden. 

3) a:  open an existing file for append operation. It won’t override existing data.

4) r+:  To read and write data into the file. The previous data in the file will not be deleted.

5) w+: To write and read data. It will override existing data.

6) a+: To append and read data from the file. It won’t override existing data.

File handling important in Python?

File handling is one of the most important parts of any language. Python language supports two types of files. The first one is a text file that store data in the form of text and readable by humans and computers. The second one is binary file that store binary data and readable by computer only

Why do we need file handling in Python?

Python file handling is one of the essential topics for programmers and automation testers. It is required to work with files for either writing to a file or read data from it.

Some Basic Syntax To open a file  f = open(“filename.txt”) f = open(“demofile.txt”, “rt”)

"r" for read, and "t" for text

Q) How to read the file?

See more about it in upcoming articles Thankyou And yes put comments ,doubts till then HAVE FUN #happycoding 🙂


You may also like...

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: