我们从Python开源项目中,提取了以下2个代码示例,用于说明如何使用cPickle.html()。
def dump(self, outfile): ''' Serialize the model for this learner and write it to a file. Serialized models can be loaded back in with `load`. By default, pickle the entire object. This may not be very efficient or reliable for long-term storage; consider overriding this (and `load`) to serialize only the necessary parameters. Alternatively, you can define __getstate__ and __setstate__ for subclasses to influence how the model is pickled (see https://docs.python.org/2/library/pickle.html). :param file outfile: A file-like object where the serialized model will be written. ''' pickle.dump(self, outfile)