I have a string like
"{0:.2f}sec/{1}".format(my_variable, other_variable) my_variable is a float . I want it to take 5 characters. For a regular variable, I would do this:
"{0: <5}".format(my_variable) I tried:
"{0:.2f <5} }sec/{1}".format(my_variable, other_variable) "{0:.2f: <5} }sec/{1}".format(my_variable, other_variable) but crashes
ValueError: Invalid conversion specification How to make my_variable take up 5 characters? Examples of output:
"23.45" " 2.34" " 0.30"
12.22, `0.23,1.70`, that is, the missing numbers are replaced with spaces. - nick_gabpe