模拟,没什么好说的
class Solution:def entityParser(self, text: str) -> str:entityMap = {'"': '"',''': "'",'>': '>','<': '<','⁄': '/','&': '&',}i = 0n = len(text)res = []while i < n:isEntity = Falseif text[i] == '&':for e in entityMap:if text[i:i + len(e)] == e:res.append(entityMap[e])isEntity = Truei += len(e)breakif not isEntity:res.append(text[i])i += 1return ''.join(res)