当前位置: 首页>>代码示例>>Python>>正文


Python rapidjson.dump方法代码示例

本文整理汇总了Python中rapidjson.dump方法的典型用法代码示例。如果您正苦于以下问题:Python rapidjson.dump方法的具体用法?Python rapidjson.dump怎么用?Python rapidjson.dump使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在rapidjson的用法示例。


在下文中一共展示了rapidjson.dump方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: save

# 需要导入模块: import rapidjson [as 别名]
# 或者: from rapidjson import dump [as 别名]
def save(self, font, path):
        d = self.unstructure(font)
        with open(path, 'w') as file:
            json.dump(d, file, indent=self._indent) 
开发者ID:trufont,项目名称:tfont,代码行数:6,代码来源:tfontConverter.py

示例2: dump

# 需要导入模块: import rapidjson [as 别名]
# 或者: from rapidjson import dump [as 别名]
def dump(obj: object, stream: bytes, *args, **kwargs) -> bytes:
    kwargs = add_settings_to_kwargs(kwargs)
    return rapidjson.dump(obj, stream, *args, **kwargs) 
开发者ID:alexferl,项目名称:falcon-boilerplate,代码行数:5,代码来源:json.py

示例3: compress_claims

# 需要导入模块: import rapidjson [as 别名]
# 或者: from rapidjson import dump [as 别名]
def compress_claims(claims):
    out = io.BytesIO()

    with gzip.open(out, mode="wt") as fo:
        json.dump(list(squashed_scopes(claims)), fo)

    return base64.encodebytes(out.getvalue()).decode() 
开发者ID:Flowminder,项目名称:FlowKit,代码行数:9,代码来源:jwt.py

示例4: to_geojson_file

# 需要导入模块: import rapidjson [as 别名]
# 或者: from rapidjson import dump [as 别名]
def to_geojson_file(self, filename, crs=None):
        """
        Export this query to a GeoJson FeatureCollection file.
        
        Parameters
        ----------
        filename : str
            File to save resulting geojson as.
        crs : int or str
            Optionally give an integer srid, or valid proj4 string to transform output to
        """
        with open(filename, "w") as fout:
            json.dump(self.to_geojson(crs=crs), fout) 
开发者ID:Flowminder,项目名称:FlowKit,代码行数:15,代码来源:geodata_mixin.py

示例5: thread

# 需要导入模块: import rapidjson [as 别名]
# 或者: from rapidjson import dump [as 别名]
def thread(players, queue_subproc, mode):
    """Handles running of the match loop"""
    uuid_ = unique_uuid("matches")
    base_agent = pommerman.agents.BaseAgent
    env = pommerman.make(
        mode,
        [base_agent(), base_agent(),
         base_agent(), base_agent()])
    net, net_end = multiprocessing.Pipe()
    queue_subproc.put([net_end, players, uuid_])
    obs = env.reset()
    record = {
        "board": numpy.array(env._board, copy=True).tolist(),
        "actions": [],
        "mode": str(mode)
    }
    done = False
    while not done:
        obs_res = resolve_classes(obs.copy())
        turn_id = str(uuid.uuid4())[:5]
        try:
            obs_bytes = []
            for key, value in enumerate(obs_res):
                if 10 + key in obs[0]["alive"]:
                    obs_bytes.append(
                        gzip.compress(
                            bytes(
                                rapidjson.dumps({
                                    "o": value,  # o = obs
                                    "i": turn_id,  # i = Turn ID
                                    "d": False  # d = Dead
                                }),
                                "utf8")))
                else:
                    obs_bytes.append(
                        gzip.compress(
                            bytes(
                                rapidjson.dumps({
                                    "d": True  # d = Dead
                                }),
                                "utf8")))
            net.send([
                constants.SubprocessCommands.match_next.value, turn_id,
                obs_bytes,
                len(obs[0]["alive"])
            ])
            act = net.recv()
        except:
            act = [0, 0, 0, 0]
        record["actions"].append(numpy.array(act, copy=True).tolist())
        obs, rew, done = env.step(act)[:3]
    record["reward"] = rew
    env.close()
    with open("./matches/" + uuid_ + ".json", "w") as file:
        rapidjson.dump(record, file)
    net.send([constants.SubprocessCommands.match_end.value, rew])
    net.recv()
    exit(0) 
开发者ID:MultiAgentLearning,项目名称:playground,代码行数:60,代码来源:match.py


注:本文中的rapidjson.dump方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。