- :e
- :E
- :f
- :F
- :g
- :G
- :n
Format floating point number
examples/format/formatted_float.py
x = 412.345678901 print("{:e}".format(x)) # exponent: 4.123457e+02 print("{:E}".format(x)) # Exponent: 4.123457E+02 print("{:f}".format(x)) # fixed point: 412.345679 (default precision is 6) print("{:.2f}".format(x)) # fixed point: 412.35 (set precision to 2) print("{:F}".format(x)) # same as f. 412.345679 print("{:g}".format(x)) # generic: 412.346 (default precision is 6) print("{:G}".format(x)) # generic: 412.346 print("{:n}".format(x)) # number: 412.346 print("{}".format(x)) # defaults to g 412.345678901