Search
 
SCRIPT & CODE EXAMPLE
 

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')
Comment

PREVIOUS NEXT
Code Example
Python :: python swap two values in list 
Python :: decision tree regressor 
Python :: csv module remove header title python 
Python :: multiple variables in for loop python 
Python :: python test if string begins with python 
Python :: standard scaler vs min max scaler 
Python :: list of numbers 
Python :: django custom save method 
Python :: how to open application using python 
Python :: sort list alphabetically python 
Python :: how to start a new django project 
Python :: discord.py fetch channel 
Python :: python notebook breakpoints 
Python :: how to remove numbers from a dataframe in python 
Python :: json url to dataframe python 
Python :: python replace string 
Python :: numpy add new column 
Python :: how to convert to string in python 
Python :: creating base models django 
Python :: convert string of list to list python 
Python :: python request response json format 
Python :: discord.py say something 
Python :: place legend on location matplotlib 
Python :: python ftplib get list of directories 
Python :: python vs c++ 
Python :: remove hyperlink from text python 
Python :: how to use turtle in python in python 3.9 
Python :: pandas change date format to yyyy-mm-dd 
Python :: how to import request library in python 
Python :: openpyxl create new file 
ADD CONTENT
Topic
Content
Source link
Name
1+9 =