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

Popular posts from this blog

c# - Outlook Add-in,group emails based on color category -

javascript - Checkbox in firefox extension -

PHP: Exploding array elements -