本文整理汇总了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