Advertisements
Advertisements
प्रश्न
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.
कोड लेखन
Advertisements
उत्तर
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
क्या इस प्रश्न या उत्तर में कोई त्रुटि है?
