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