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


Python msgpack.pack方法代碼示例

本文整理匯總了Python中msgpack.pack方法的典型用法代碼示例。如果您正苦於以下問題:Python msgpack.pack方法的具體用法?Python msgpack.pack怎麽用?Python msgpack.pack使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在msgpack的用法示例。


在下文中一共展示了msgpack.pack方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: dump

# 需要導入模塊: import msgpack [as 別名]
# 或者: from msgpack import pack [as 別名]
def dump(obj, f, **kwargs):
    """ An overload of msgpack.dump that works with pyGSTi types """
    enc = encode_obj(obj, msgpack_uses_binary_strs)
    _msgpack.pack(enc, f, **kwargs) 
開發者ID:pyGSTio,項目名稱:pyGSTi,代碼行數:6,代碼來源:msgpack.py

示例2: store_trajs

# 需要導入模塊: import msgpack [as 別名]
# 或者: from msgpack import pack [as 別名]
def store_trajs(trajs, store_to):
    """Store trajectories to store_to/trajs.data."""
    if not os.path.exists(store_to):
        os.makedirs(store_to)
    file_path = os.path.join(store_to, 'trajs.data')
    with open(file_path, 'wb') as file:
        msgpack.pack(trajs, file) 
開發者ID:JohannesHeidecke,項目名稱:irl-benchmark,代碼行數:9,代碼來源:__init__.py

示例3: dump

# 需要導入模塊: import msgpack [as 別名]
# 或者: from msgpack import pack [as 別名]
def dump(obj, fp, default=None):
    msgpack.pack(obj, fp, use_bin_type=True, default=default) 
開發者ID:namuyan,項目名稱:p2p-python,代碼行數:4,代碼來源:serializer.py

示例4: persist

# 需要導入模塊: import msgpack [as 別名]
# 或者: from msgpack import pack [as 別名]
def persist(self):
        with open(self.path, 'wb+') as f:
            raw = {'count': self.count, 'term': self.term, 'data': self.data}
            msgpack.pack(raw, f, use_bin_type=True) 
開發者ID:simonacca,項目名稱:zatt,代碼行數:6,代碼來源:log.py

示例5: dump

# 需要導入模塊: import msgpack [as 別名]
# 或者: from msgpack import pack [as 別名]
def dump(obj, fp, registry=None):
    """Serialize ``obj`` as a messagepack formatted stream to ``fp``.

    .. versionchanged:: 1.5
       Added *registry* parameter.
    """
    if registry is None:
        registry = default_registry
    return msgpack.pack(obj, fp,
                        default=functools.partial(_serializer, registry),
                        use_bin_type=True) 
開發者ID:openstack,項目名稱:oslo.serialization,代碼行數:13,代碼來源:msgpackutils.py

示例6: dump

# 需要導入模塊: import msgpack [as 別名]
# 或者: from msgpack import pack [as 別名]
def dump(self, file_path, obj, encoding="utf-8"):
        path = self.cache_path / file_path
        path.parent.mkdir(parents=True, exist_ok=True)

        try:
            with open(path.with_suffix(".msgpack"), "wb") as out_file:
                msgpack.pack(obj, out_file, encoding=encoding)
        except TypeError:
            os.remove(path.with_suffix(".msgpack"))
            with open(path.with_suffix(".pkl"), "wb") as out_file:
                pickle.dump(obj, out_file, protocol=pickle.HIGHEST_PROTOCOL) 
開發者ID:naver,項目名稱:claf,代碼行數:13,代碼來源:data_handler.py


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