Files

11 lines
369 B
Python
Raw Permalink Normal View History

import re
def normalize_en_answer(text: str) -> str:
"""英文拼写/短语答案:去首尾空白、小写、连续空白压成单个空格。"""
return re.sub(r"\s+", " ", (text or "").strip().lower())
def en_answers_match(user_answer: str, correct_answer: str) -> bool:
return normalize_en_answer(user_answer) == normalize_en_answer(correct_answer)