Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

pickling and unpickling in python

import pickle

# Writing information using pickle libary
mylist = [2,3,5,8]  # List to load
myfile = open("fileName.txt","wb") # Open file for writing in binary
pickle.dump(mylist,myfile) # Load list into file
myfile.close() # Close the file

# Reading information using pickle libary
myfile = open("fileName.txt","rb") # Open file for reading in binary
object_in_file = pickle.load(myfile) # Load file
print(object_in_file) # Print retrived information
 
PREVIOUS NEXT
Tagged: #pickling #unpickling #python
ADD COMMENT
Topic
Name
9+3 =