, . format
. Python 2 12 ( , ) float.__str__
, :
>>> str(0.3000000000004)
'0.3'
format_spec
:f
6:
>>> '{:f}'.format(0.3000000000004)
'0.300000'
repr
, :
>>> '{!r}'.format(0.3000000000004)
'0.3000000000004'
Python 3 , :
>>> str(0.3000000000004)
'0.3000000000004'
float float_repr
Python 3 ( float_str
):
(reprfunc)float_repr,
...
(reprfunc)float_repr,
Python2.7 float_str
float_repr
__str__
__repr__
:
(reprfunc)float_repr,
...
(reprfunc)float_str,
, , , 12d.p. PyFloat_STR_PRECISION
( Python 2):
#define PyFloat_STR_PRECISION 12
float, 12 .