Advertisements
Advertisements
Question
A Binary file, CINEMA.DAT has the following structure:
{MNO:[MNAME, MTYPE]}
Where
- MNO - Movie Number
- MNAME - Movie Name
- MTYPE is Movie Type
Write a user defined function, findType(mtype), that accepts mtype as parameter and displays all the records from the binary file CINEMA.DAT, that have the value of Movie Type as mtype.
Short/Brief Note
Advertisements
Solution
def Searchtype (mtype) :
fObj = open("CINEMA.DAT", "rb")
try:
while True:
data = pickle.load(fObj)
if data[2] == mtype:
print ("Movie number:",data[0])
print ("Movie Name:",data[1])
print ("Movie Type:",data[2])
except EOFError:
fObj.close ()
shaalaa.com
The Pickle Module in Python
Is there an error in this question or solution?
