Minor formatting issue: Im having trouble dealing with these kinda values:
97 $ 7.922816251426434e+26
98 $ 1.5845632502852868e+27
99 $ 3.1691265005705736e+27
100 $ 6.338253001141147e+27
I want to make it print normally(?) with just 2 decimal places and the full number not the e+27 in the end..
Thanks for your help in advance!
"%.2f" % value
Since python 3, you may as well use string.format :
"{:.2f}".format(value)
which looks more complicated, but is more modern and more powerful and worth getting used to ;)
Try using format
:
' {0:.2f}'.format(num)
Explanation:
{0}
tells format to print the first argument -- in this case, num
.
Everything after the colon (:)
specifies the format_spec.
f
Fixed point. Displays the number as a fixed-point number. The default precision is 6.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.