Q. What will be the output of the following code?
import pickle ID = {1: "Ziva", 2: "53050", 3: "IT",4: "38",5: "Dunzo"} fin = open("Emp.pkl","wb") pickle.dump(EmpID, fin) fin.close() fout = open("Emp.pkl", 'rb') ID = pickle.load(fout) print( ID [5] )
Answer =
It produces an error that ‘EmpID’ is not defined.
If
we modify the code or define the EmpID as ID then:-
import
pickle
ID = {1: "Ziva", 2: "53050", 3: "IT",4: "38",5: "Dunzo"}
fin
= open("Emp.pkl","wb")
pickle.dump(ID, fin)
fin.close()
fout =
open("Emp.pkl", 'rb')
ID = pickle.load(fout)
print( ID [5] )
Output:-
Dunzo
>>>
What's the meaning of dunzo??
ReplyDeleteIt is written in Question. that is Output .
DeleteAre you alright?! 😅
DeletePost a Comment
You can help us by Clicking on ads. ^_^
Please do not send spam comment : )