本文整理汇总了Python中msgpack.unpack方法的典型用法代码示例。如果您正苦于以下问题:Python msgpack.unpack方法的具体用法?Python msgpack.unpack怎么用?Python msgpack.unpack使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类msgpack
的用法示例。
在下文中一共展示了msgpack.unpack方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: load
# 需要导入模块: import msgpack [as 别名]
# 或者: from msgpack import unpack [as 别名]
def load(f, **kwargs):
""" An overload of msgpack.load that works with pyGSTi types """
decoded_msgpack = _msgpack.unpack(f, **kwargs) # load normal MSGPACK
return decode_obj(decoded_msgpack, msgpack_uses_binary_strs) # makes pygsti objects
示例2: load_stored_trajs
# 需要导入模块: import msgpack [as 别名]
# 或者: from msgpack import unpack [as 别名]
def load_stored_trajs(load_from):
"""Return trajectories storead at load_from/trajs.data."""
file_path = os.path.join(load_from, 'trajs.data')
with open(file_path, 'rb') as file:
trajs = msgpack.unpack(file)
# convert byte keys back to string keys:
trajs = [{
key.decode('utf-8') if isinstance(key, bytes) else key: traj[key]
for key in traj.keys()
} for traj in trajs]
return trajs
示例3: load
# 需要导入模块: import msgpack [as 别名]
# 或者: from msgpack import unpack [as 别名]
def load(fp, object_hook=None):
return msgpack.unpack(fp, object_hook=object_hook, encoding='utf8')
示例4: __init__
# 需要导入模块: import msgpack [as 别名]
# 或者: from msgpack import unpack [as 别名]
def __init__(self, count=0, term=None, data={}):
self.count = count
self.term = term
self.data = data
self.path = os.path.join(config.storage, 'compact')
# load
logger.debug('Initializing compactor')
if count or term or data:
self.persist()
logger.debug('Using parameters')
elif os.path.isfile(self.path):
with open(self.path, 'rb') as f:
self.__dict__.update(msgpack.unpack(f, encoding='utf-8'))
logger.debug('Using persisted data')
示例5: _load_msgpack
# 需要导入模块: import msgpack [as 别名]
# 或者: from msgpack import unpack [as 别名]
def _load_msgpack(self, path, encoding):
with open(path, "rb") as in_file:
return msgpack.unpack(in_file, encoding=encoding)
示例6: parse
# 需要导入模块: import msgpack [as 别名]
# 或者: from msgpack import unpack [as 别名]
def parse(self, stream, media_type=None, parser_context=None):
if not msgpack:
raise _import_error
return msgpack.unpack(stream, use_list=False, encoding='utf-8')