浏览代码

urllib parse

/develop/cubewars
Andrew Cohen 5 年前
当前提交
54ad09a3
共有 1 个文件被更改,包括 6 次插入7 次删除
  1. 13
      ml-agents/mlagents/trainers/behavior_id_utils.py

13
ml-agents/mlagents/trainers/behavior_id_utils.py


from typing import NamedTuple
from urllib.parse import urlparse, parse_qs
class BehaviorIdentifiers(NamedTuple):

:returns: A BehaviorIdentifiers object.
"""
parsed = urlparse(name_behavior_id)
name = parsed.path
ids = parse_qs(parsed.query)
if "?" in name_behavior_id:
name, team_and_id = name_behavior_id.rsplit("?", 1)
_, team_id_str = team_and_id.split("=")
team_id = int(team_id_str)
else:
name = name_behavior_id
if "team" in ids:
team_id = int(ids["team"][0])
return BehaviorIdentifiers(
behavior_id=name_behavior_id, brain_name=name, team_id=team_id
)
正在加载...
取消
保存