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


Python _pickle.loads方法代碼示例

本文整理匯總了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() 
開發者ID:bhansconnect,項目名稱:alpha_zero_othello,代碼行數:26,代碼來源:history.py

示例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) 
開發者ID:neka-nat,項目名稱:distributed_rl,代碼行數:7,代碼來源:utils.py

示例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 
開發者ID:CIRCL,項目名稱:douglas-quaid,代碼行數:10,代碼來源:pickle_import_export.py

示例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) 
開發者ID:openbci-archive,項目名稱:OpenBCI_Python,代碼行數:15,代碼來源:udp_client.py

示例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 
開發者ID:ibm-dev-incubator,項目名稱:demoparser,代碼行數:28,代碼來源:entity_list.py

示例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 
開發者ID:bhansconnect,項目名稱:alpha_zero_othello,代碼行數:14,代碼來源:replaybuffer.py


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