📌  相关文章
📜  如何将 python 对象保存在文件中 - Python 代码示例

📅  最后修改于: 2022-03-11 14:45:45.036000             🧑  作者: Mango

代码示例1
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')