本文整理匯總了Python中cPickle.html方法的典型用法代碼示例。如果您正苦於以下問題:Python cPickle.html方法的具體用法?Python cPickle.html怎麽用?Python cPickle.html使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類cPickle
的用法示例。
在下文中一共展示了cPickle.html方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: dump
# 需要導入模塊: import cPickle [as 別名]
# 或者: from cPickle import html [as 別名]
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)
示例2: write_gpickle
# 需要導入模塊: import cPickle [as 別名]
# 或者: from cPickle import html [as 別名]
def write_gpickle(G, path, protocol=pickle.HIGHEST_PROTOCOL):
"""Write graph in Python pickle format.
Pickles are a serialized byte stream of a Python object [1]_.
This format will preserve Python objects used as nodes or edges.
Parameters
----------
G : graph
A NetworkX graph
path : file or string
File or filename to write.
Filenames ending in .gz or .bz2 will be compressed.
protocol : integer
Pickling protocol to use. Default value: ``pickle.HIGHEST_PROTOCOL``.
Examples
--------
>>> G = nx.path_graph(4)
>>> nx.write_gpickle(G, "test.gpickle")
References
----------
.. [1] http://docs.python.org/library/pickle.html
"""
pickle.dump(G, path, protocol)
示例3: read_gpickle
# 需要導入模塊: import cPickle [as 別名]
# 或者: from cPickle import html [as 別名]
def read_gpickle(path):
"""Read graph object in Python pickle format.
Pickles are a serialized byte stream of a Python object [1]_.
This format will preserve Python objects used as nodes or edges.
Parameters
----------
path : file or string
File or filename to write.
Filenames ending in .gz or .bz2 will be uncompressed.
Returns
-------
G : graph
A NetworkX graph
Examples
--------
>>> G = nx.path_graph(4)
>>> nx.write_gpickle(G, "test.gpickle")
>>> G = nx.read_gpickle("test.gpickle")
References
----------
.. [1] http://docs.python.org/library/pickle.html
"""
return pickle.load(path)
# fixture for nose tests
示例4: write_gpickle
# 需要導入模塊: import cPickle [as 別名]
# 或者: from cPickle import html [as 別名]
def write_gpickle(G, path, protocol=pickle.HIGHEST_PROTOCOL):
"""Write graph in Python pickle format.
Pickles are a serialized byte stream of a Python object [1]_.
This format will preserve Python objects used as nodes or edges.
Parameters
----------
G : graph
A NetworkX graph
path : file or string
File or filename to write.
Filenames ending in .gz or .bz2 will be compressed.
protocol : integer
Pickling protocol to use. Default value: ``pickle.HIGHEST_PROTOCOL``.
Examples
--------
>>> G = nx.path_graph(4)
>>> nx.write_gpickle(G, "test.gpickle")
References
----------
.. [1] https://docs.python.org/2/library/pickle.html
"""
pickle.dump(G, path, protocol)
示例5: read_gpickle
# 需要導入模塊: import cPickle [as 別名]
# 或者: from cPickle import html [as 別名]
def read_gpickle(path):
"""Read graph object in Python pickle format.
Pickles are a serialized byte stream of a Python object [1]_.
This format will preserve Python objects used as nodes or edges.
Parameters
----------
path : file or string
File or filename to write.
Filenames ending in .gz or .bz2 will be uncompressed.
Returns
-------
G : graph
A NetworkX graph
Examples
--------
>>> G = nx.path_graph(4)
>>> nx.write_gpickle(G, "test.gpickle")
>>> G = nx.read_gpickle("test.gpickle")
References
----------
.. [1] https://docs.python.org/2/library/pickle.html
"""
return pickle.load(path)
# fixture for nose tests