在Python
作为“ 1.00000E-05”的商显示。您想抑制此符号并将其显示为“ 0.00001”作为字符串。print("{:.5f}".format(x/y))
This will display the quotient as "0.00001."
Using Formatted String Literals (Python 3.6 ):
In Python 3.6 and later, you can use格式化的字符串文字以简化过程。语法如下:
print(f“ {x/y:.5f}”)x = 1.0 y = 100000.0 print(x/y),与''.format()方法。 y = 100000.0 结果= f“ {x/y:.5f}” print(result)
0.00001
通过使用这些方法,您可以抑制科学符号,当打印浮点数时,并获得所需的字符串格式。免责声明: 提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发到邮箱:[email protected] 我们会第一时间内为您处理。
Copyright© 2022 湘ICP备2022001581号-3