Binary File - load() Function


☞ To write data on a binary file, we use load() function.

☞ import a pickle module to use this function.

☞ It is used to deserialize the byte stream into python object like list, dictionary etc.

Syntax : pickle.load("file_object")

Example

 #reading data from a binary file. 

import pickle

def reading_data():
    f = open("demo.bin","rb")
    L=pickle.load(f)
    print(L)
    f.close()

reading_data()#calling a function