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

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -