import pickle
'''#pickling a python object
friends=["vijay","shankar","raju"]
file="friends.pkl" #define a pickle file
fileobj=open(file,"wb") #pickle file object in write binary(wb) mode
pickle.dump(friends,fileobj) #dump method is used to add content to the pickle file
fileobj.close()
#we cannot read simply pickle file in text format because it is of binary format'''
#reading a pickle file
fileobj=open("friends.pkl","rb")
myfriends=pickle.load(fileobj) #load method is used to read a pickle file
print(myfriends)
fileobj.close()
Comments
Post a Comment