How in python to transfer a variable to the place "2" in a format construction?
print("{0:.2f}".format(7.18345)) To make it like this:
print("{0:.(a)f}".format(7.18345)) The language in the format-template supports nested substitutions:
print("{:.{precision}f}".format(7.18345, precision=2)) # -> 7.18 Source: https://ru.stackoverflow.com/questions/604565/
All Articles