Advertisements
Advertisements
Question
A binary file, EMP.DAT has the following structure:
[Emp Id, Name, Salary]
where Emp_Id: Employee id Name: Employee Name Salary: Employee Salary
Write a user defined function, disp_Detail(), that would read the contents of the file EMP.DAT and display the details of those employees whose salary is below 25000.
Code Writing
Advertisements
Solution
import pickle
def disp_Detail():
f=open("EMP.dat","rb")
try:
while True:
erec=pickle.load(f)
if int(erec[2]}<25000:
print(erec)
except EOFError:
pass
f.close() shaalaa.com
Is there an error in this question or solution?
