【问题标题】:How to convert a negative exponential number into a decimal number in Python?如何在 Python 中将负指数数转换为十进制数?
【发布时间】:2021-07-11 14:03:18
【问题描述】:

例如,我很难转换以下数字:

-1.9443404027234424e+46
-1.9443404027234425e+36

采用不带科学记数法的格式(例如 0.04256 之类的浮点数)。

【问题讨论】:

标签: python floating-point numbers scientific-notation


【解决方案1】:

您可以使用:f format specifier:

>>> print("{:.0f}".format(-1.9443404027234424e+46))
-19443404027234423757622069004479676797119627264

请注意,由于浮点精度,结果可能不会以 46 个零结尾。

【讨论】:

    猜你喜欢
    • 2010-12-07
    • 2019-04-30
    • 1970-01-01
    • 2011-12-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多