Research portable Memory game | Исследовать портируемую игру Память
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

3 个月前
12345678910111213141516171819202122232425262728
  1. class Type:
  2. def __init__(self, s):
  3. # Currently no recursion is allowed,
  4. # so you can't have a dictionary in dictionary.
  5. self.name = None
  6. self.first = None
  7. self.second = None
  8. # Dictionary.
  9. if s.startswith("std::map"):
  10. self.name = "map"
  11. # Remove prefix and suffix.
  12. prefix = "std::map<"
  13. s = s[len(prefix):]
  14. suffix = ">"
  15. s = s[:-len(suffix)]
  16. # Get map types.
  17. parts = s.split(", ")
  18. self.first = parts[0]
  19. self.second = parts[1]
  20. # By default we treat the type as is.
  21. else:
  22. self.name = s
  23. def __repr__(self):
  24. return self.__str__()
  25. def __str__(self):
  26. return f"Type(n/f/s: '{self.name}'/'{self.first}'/'{self.second}')"