Python Tutorial | Python Data File Handling 15

Example:10
Python program to read empno,name and salary stored in the above binary file.( in example:9)
Sol:

# to read data from a binary file
import pickle
f=open("emp","rb")
temp=pickle.load(f)
f.close()
#print(temp)
for rec in temp:
    for field in rec.split():
        print(field,end='\t')
    print('\n')

Output:

1001	abc	12000.0	

1002	xyz	23000.0	

1003	aaa	25000.0	

>>> 

Visitor Counter

0056741