当前位置: 首页>>代码示例>>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;未经允许,请勿转载。