Hello,
How can I control the representation of my exponential number?
4.840000E+02 need to define how many numbers I want after the point?
Is there a way to define it when I create it from integer?
Thank you very much
Hello,
How can I control the representation of my exponential number?
4.840000E+02 need to define how many numbers I want after the point?
Is there a way to define it when I create it from integer?
Thank you very much
'e' Floating point exponential format (lowercase). (3)
'E' Floating point exponential format (uppercase). (3)
The alternate form causes the result to always contain a decimal point, even if no digits follow it.The precision determines the number of digits after the decimal point and defaults to 6.
Straight from documents you know so well (http://docs.python.org/library/stdtypes.html#string-formatting). Here test:
>>> number= 4.840000E+02
>>> print number
484.0
>>> print "%e" % number
4.840000e+02
>>> print "%.3E" % number
4.840E+02
>>> print "%.3e" % number
4.840e+02
>>>
That's what I wanted!!!
Thank you!!
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.