Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

how to save a python object in a file

def save_object(obj, filename):
    with open(filename, 'wb') as outp:  # Overwrites any existing file.
        pickle.dump(obj, outp, pickle.HIGHEST_PROTOCOL)

# sample usage
save_object(company1, 'company1.pkl')
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #save #python #object #file
ADD COMMENT
Topic
Name
4+2 =