Suppose I have x=3.141516 and y=0.00129. I need to format those numbers in scientific notation but the mantissa must not have decimal places. For example:
x = 3141516e-6
y = 129e-5
I have no idea how to solve this, since formatting in Python looks always assume decimal places.
I'm not aware how you can do it with
str.format(to not have any decimal places), but you can construct the string manually (with help ofdecimalmodule):Prints: