0% found this document useful (0 votes)
5 views15 pages

File Handling - Python

File handling involves operations such as creating, opening, reading, writing, and closing files through a programming interface, particularly in Python. It allows for the permanent storage of data on disk, as opposed to temporary storage in variables. Python provides built-in functions for various file operations, including modes for reading, writing, and appending data.

Uploaded by

fall3210060
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views15 pages

File Handling - Python

File handling involves operations such as creating, opening, reading, writing, and closing files through a programming interface, particularly in Python. It allows for the permanent storage of data on disk, as opposed to temporary storage in variables. Python provides built-in functions for various file operations, including modes for reading, writing, and appending data.

Uploaded by

fall3210060
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 15

File Handling

File Handling

• File handling refers to the process of performing operations on a


file such as creating, opening, reading, writing and closing it,
through a programming interface. It involves managing the data
flow between the program and the file system on the storage
device, ensuring that data is handled safely and efficiently.

• File handling in Python involves interacting with files on your


computer to read data from them or write data to them. Python
provides several built-in functions and methods for creating,
opening, reading, writing, and closing files.
Conti…

• File : File is nothing but name of memory location on disk


that store data permanently.
• Data are also stored in variables for example a=10 when
program executed then we can access it when program
execution is terminated the memory will destroy

• But when we store data in files it will store permanently


when execution terminated the memory will not destroy .
File handling

• File handling is a mechanism through which we can handle


( read, write, create append etc..) the file.

• Syntax :-- file_obj = open(‘file_path’, ‘Mode’)

Open ( ) is a function to work with files and it takes two


parameters.
File Mode File operations

• r = read create ( )

• w = write read ( )

• a = append write ( )

• r+ = read and write copy ( )

• b = binary mode delete ( )


How to create a File
How to write data in File
How to Append data in File
How to read data from File
Conti…
Conti…
Reading data From a File not Exist
Reading data From a File Exist
Copy data From one file to another File
How to delete a File

You might also like