Search
 
SCRIPT & CODE EXAMPLE
 

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
Comment

PREVIOUS NEXT
Code Example
Python :: correlation python 
Python :: how to get the current year in python 
Python :: separate path python 
Python :: df = df.reset_index(level=0) 
Python :: round to the nearest integer python 
Python :: dataframe drop rows by column value 
Python :: pandas create new column conditional on other columns 
Python :: radix sort python 
Python :: python program to draw square 
Python :: how to read numbers from a text file in python 
Python :: python to create pandas dataframe 
Python :: code to calculate dice score 
Python :: how to add a number to each element in an array python with loop 
Python :: example of django template for forms 
Python :: remove duplicates function python 
Python :: create exe from python script 
Python :: python google chrome 
Python :: numpy count occurrences in array 
Python :: python set grid thickness 
Python :: python count characters 
Python :: pandas fill nan methods 
Python :: matplotlib savefig not working 
Python :: keras.layers.simplernn 
Python :: run powershell script in python 
Python :: set seed train test split 
Python :: python letter to number in alphabet 
Python :: python file.write is not writing whole line 
Python :: smtplib send pdf 
Python :: how to calculate sum of a list in python 
Python :: how to press enter in selenium python 
ADD CONTENT
Topic
Content
Source link
Name
1+7 =