【发布时间】:2020-12-07 14:32:22
【问题描述】:
如何打印具有 2.6000000000000001 的 2.7。 (或任何其他类似的数字)。
import math
print(math.ceil(2.6000000000000001)) // 3
print(round(2.6000000000000001, 2)) // 2.6
???
【问题讨论】:
-
ceil(x * 10) / 10或。确保在逗号后只打印一个位置f"{ceil(x * 10) / 10:.1f}"。
标签: python-3.x math rounding