本文整理匯總了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