四舍五入,来自 Python 3 和 extra 中的 .txt 变量

Rounding, variable from a .txt in Python 3 and extra

if op in ["/"]:
    # rounding does not rounds half up so I imported a module
    from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_DOWN
    Decimal(str(answer)).quantize(Decimal("1.11"), rounding=ROUND_HALF_UP)
    Decimal(str(given_answer)).quantize(Decimal("1.11"), rounding=ROUND_HALF_UP)
print("correct {}".format(answer, ".2f"))

49//34=?1.44

correct 1

Wrong answer!

如果真实答案是 3.55865465,我希望它的正确答案是 3.56。我做错了什么?

尝试将最后一行更改为以下内容:

print("correct {:.2f}".format(answer))