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
No comments:
Post a Comment
for more information please share like comment and subscribe