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