找出分币解析器里的 bug

来自 变量与数据类型
Python 3.14 进阶 5分钟 找出 2处问题

找出这个辅助函数为什么会接受不符合整数分值契约的值。

Python
def record_cents(record: dict[str, object]) -> int:
    cents = record.get("cents") or 0
    if not isinstance(cents, int):
        raise ValueError("cents must be an integer")
    return cents
在试验场中打开
报告错误