以下是我的代码:
x = 1.0
y = 100000.0
print x/y
我的商显示为1.00000e-05
.
有没有办法取消科学记数法并使其显示为
0.00001
?我将使用结果作为字符串.
以下是我的代码:
x = 1.0
y = 100000.0
print x/y
我的商显示为1.00000e-05
.
有没有办法取消科学记数法并使其显示为
0.00001
?我将使用结果作为字符串.
'%f' % (x/y)
但你需要自己管理好精确度.例如,
'%f' % (1/10**8)
will display zeros only.
details are in the docs
或者Python3the equivalent old formatting或newer style formatting