python - Missing type to str.format() behavior -
according python docs here, when leaving type out, defaults type of 'g' floating point arguments.
however,
print("{0:.2}".format(14.9))
prints "1.5e+01", while
print("{0:.2g}".format(14.9))
prints "15"
is issue of documentation being incorrect or there reason it?
according source code, documentation bug. correct description behaviour without floating point specifier "like 'g', @ least 1 digit after decimal point".
Comments
Post a Comment