string formatting - Is there a way to set the default float presentation for Python "{:5.3e}".format(a) if a=None and is not a float? -
is there easy way set default float presentation python's format command:
"{:5.3e}".format(a)
so if variable has value of none instead of float, default 5 spaces might printed?
the format string can include many fields , given user. values in calculated internally.
i suggest like
print("{:.3e}".format(a)) if else print(" "*5).
you don't need 5.3e
since in scientific notation 5 digits because of .3e. except want shift whole text right. use {:>10.3e}
.
Comments
Post a Comment