本文整理汇总了Python中_pickle.loads方法的典型用法代码示例。如果您正苦于以下问题:Python _pickle.loads方法的具体用法?Python _pickle.loads怎么用?Python _pickle.loads使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类_pickle
的用法示例。
在下文中一共展示了_pickle.loads方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: start
# 需要导入模块: import _pickle [as 别名]
# 或者: from _pickle import loads [as 别名]
def start():
config = DataConfig()
histories = sorted(glob.glob(config.history_location+"*.pickle"))
data = {}
for hist in histories:
file = open(hist, 'rb')
h = pickle.loads(pickle.load(file))
for k, v in h.items():
if k not in data.keys():
data[k] = []
for item in v:
data[k].append(item)
legend = []
plt.subplot(2, 1, 1)
for kv in data.items():
legend.append(kv[0])
plt.plot(kv[1])
plt.legend(legend)
for i, kv in enumerate(data.items()):
plt.subplot(2, 3, i+4)
plt.title(kv[0])
plt.plot(kv[1])
plt.tight_layout()
plt.show()
示例2: loads
# 需要导入模块: import _pickle [as 别名]
# 或者: from _pickle import loads [as 别名]
def loads(packed):
if _USE_COMPRESS:
return cPickle.loads(lz4.frame.decompress(packed))
else:
return cPickle.loads(packed)
示例3: get_object_from_pickle
# 需要导入模块: import _pickle [as 别名]
# 或者: from _pickle import loads [as 别名]
def get_object_from_pickle(pickle_obj):
# Return an object from the pickle version of it
# The protocol version used is detected automatically, so we do not
# have to specify it.
return cPickle.loads(pickle_obj)
# non static, to be sure we patched it before use, only once
示例4: start_listening
# 需要导入模块: import _pickle [as 别名]
# 或者: from _pickle import loads [as 别名]
def start_listening(self, callback=None):
while True:
data, addr = self.client.recvfrom(1024)
print("data")
if self.json:
sample = json.loads(data)
# In JSON mode we only recieve channel data.
print(data)
else:
sample = pickle.loads(data)
# Note that sample is an OpenBCISample object.
print(sample.id)
print(sample.channel_data)
示例5: new_entity
# 需要导入模块: import _pickle [as 别名]
# 或者: from _pickle import loads [as 别名]
def new_entity(self, index, class_id, serial):
"""Create new entity.
:returns: Created entity.
"""
if self._entities[index]:
self._entities[index] = None
baseline = self.parser.instance_baselines[class_id]
cls = BaseEntity
# Find an entity class based on which tables are in its baseline.
# Class IDs don't seem to be consistent across demo files so all
# you can do is assume if an entity baseline has 'DT_Team' it must
# be a Team.
for table in baseline:
if table in self.class_map:
cls = self.class_map[table]
break
new_baseline = pickle.loads(pickle.dumps(baseline))
assert baseline == new_baseline
entity = cls(self.parser, index, class_id, serial, new_baseline)
self._entities[index] = entity
return entity
示例6: load
# 需要导入模块: import _pickle [as 别名]
# 或者: from _pickle import loads [as 别名]
def load(self, filename):
try:
file = open(filename, 'rb')
if len(self.buffer) == 0:
self.buffer = pickle.loads(pickle.load(file))
else:
buf = pickle.loads(pickle.load(file))
self.merge(buf)
file.close()
return True
except Exception as e:
return False