w3ajay

tally tutorial point, ms word 2013, ms excel 2013, ms powerpoint 2010,ccc question with answer in hindi 2021, Tally Prime in hindi , tally prime,Python,in python,programming in python,python

Tuesday, July 23, 2024

What is binary file in python class 12 with example



 Part-1

What is binary file in python class 12

Binary Files are used to store different format of data. It can store large amount of data. It's Extension is .dat. In binary files data is store in the same way as stored in Hard Disk / storage device. It is secured . Binary file content can be read by only Program. Binary File store the DATA in byte stream.  


Pickling (Serialization):

It is the Process of data (object) convert in to  a Byte Stream. 

Unpickling( De-Serialization):

It is the reverse operation  of  a byte stream is converted in to Data (object)




Writing the Binary file:

for writing Binary file we use to dump() function

Reading the Binary file:

for reading file we use to load() function 

Pickle Module:

for use dump() and load() function we have to use pickle module. The pickle module provides the following functions to make the pickling process more convenient

File opening Mode:

1. rb  Mode:

                1- Read Mode
                2- Default Mode
                3- Cursor is present at the top
                4- It will give error if the file not found 

2. wb Mode:

                1- Write mode
                2- Always create a new file 
                3-  Cursor(file handle) is present at the top
                4- if same file is created then it will be delete it and will create a new file 

3. ab Mode:

               1- append Mode
               2- Opens the file and preserves previous contents 
               3-  Cursor(file handle) is present at the last 
                4- if the file not present then it opens a new blanks file 

4. rb+  -------read and write

5. wb+  ----------write and read

6- ab+   ----------- append and read

                













No comments:

Post a Comment

for more information please share like comment and subscribe