當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。