[英]Display floating point number in decimal form in Python?
Let's say I have the following float point number in Python 假设我在Python中具有以下浮点数
>>>a = 10 ** -10
>>>print a
1e-10
How can I display .0000000001
instead of 1e-10
? 如何显示.0000000001
而不是1e-10
?
>>> a = "%0.10f" % (10 ** -10)
>>> a
'0.0000000001'
Maybe a bit more readable: 也许更具可读性:
a = float("1e-10")
format(a, ".10f")
Output 输出量
'0.0000000001' '0.0000000001'
Or using format
或使用format
>>> a = 10 ** -10
>>> '{a:0.10f}'.format(a=a)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.