當前位置: 首頁>>代碼示例>>Python>>正文


Python cPickle.html方法代碼示例

本文整理匯總了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) 
開發者ID:stanfordnlp,項目名稱:stanza-old,代碼行數:17,代碼來源:learner.py

示例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) 
開發者ID:SpaceGroupUCL,項目名稱:qgisSpaceSyntaxToolkit,代碼行數:30,代碼來源:gpickle.py

示例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 
開發者ID:SpaceGroupUCL,項目名稱:qgisSpaceSyntaxToolkit,代碼行數:32,代碼來源:gpickle.py

示例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) 
開發者ID:holzschu,項目名稱:Carnets,代碼行數:30,代碼來源:gpickle.py

示例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 
開發者ID:holzschu,項目名稱:Carnets,代碼行數:32,代碼來源:gpickle.py


注:本文中的cPickle.html方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。