["python"]
Truncate to three decimals in Python

How do I get 1324343032.324? As you can see below, the following do not work: >>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'
You can use an additional float() around it if you want to preserve it as a float. val = '%.3f'%(1324343032.324325235)