我如何获得 1324343032.324?
如下所示,以下方法不起作用:
>>1324343032.324325235 * 1000 / 1000
1324343032.3243253
>>int(1324343032.324325235 * 1000) / 1000.0
1324343032.3239999
>>round(int(1324343032.324325235 * 1000) / 1000.0,3)
1324343032.3239999
>>str(1324343032.3239999)
'1324343032.32'
最佳答案
如果您想将其保留为 float
,您可以在其周围使用额外的 float()
。
%.3f'%(1324343032.324325235)
关于python - 在 Python 中截断为小数点后三位,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8595973/