Q. Consider the following definition of dictionary Member, write a method in python to write the content in a pickled file member.dat.
Member = {'MemberNo.': _____, 'Name': _____}
Answer =
import pickle file = open("member.dat","wb") while True : dic={} no = int(input("Enter memberbno. :-")) name = input("Enter name:-") dic[ "Memberno."] = no dic["Name"] = name pickle.dump( dic, file ) user = input("For quit enter quit :-") if user == "quit": break print("Thankyou") file.close()
Output :-
Enter memberbno. :- 1
Enter name:- Path
For quit enter quit :- no
Enter memberbno. :- 5
Enter name:- Walla
For quit enter quit :- no
Enter memberbno. :- 8
Enter name:- Portal
For quit enter quit :- no
Enter memberbno. :- 9
Enter name:- Express
For quit enter quit :- quit
Thankyou
>>>
Enter name:- Path
For quit enter quit :- no
Enter memberbno. :- 5
Enter name:- Walla
For quit enter quit :- no
Enter memberbno. :- 8
Enter name:- Portal
For quit enter quit :- no
Enter memberbno. :- 9
Enter name:- Express
For quit enter quit :- quit
Thankyou
>>>
Output in member.dat file :-
It stores all input data.
Ok
ReplyDelete😊
DeletePlease do not send spam comment :)
ReplyDeleteWhich comment ???
Delete😱👋
ReplyDelete: )
DeleteThanku
ReplyDeleteWelcome : )
DeletePost a Comment
You can help us by Clicking on ads. ^_^
Please do not send spam comment : )