How to properly use string formatting in Python 2.7? -


ok, please bear me, i'm new this. school, , exact syntax isn't important here assignment, own personal knowledge want know little more string formatting.

whenever use %f defaults 2 decimal places. there string format can use on float show float number of decimals has?

for instance list contains 2.0, 2.01, 2.001, 2.0001 , want use string format print them look. format code use or how use %f if possible?

this in python 2.7 on windows 7(if matters).

%g may you're looking for:

>>> "%g, %g, %g, %g" % (2.1, 2.01, 2.001, 2.0001) '2.1, 2.01, 2.001, 2.0001' 

Comments

Popular posts from this blog

android - getbluetoothservice() called with no bluetoothmanagercallback -

sql - ASP.NET SqlDataSource, like on SelectCommand -

ios - Undefined symbols for architecture armv7: "_OBJC_CLASS_$_SSZipArchive" -