I use python 3.4 and I can format strings in two ways:
print("%d %d" %(1, 2))
and
print("{:d} {:d}".format(1, 2))
In documentation they show examples only using 'format'. Do it mean that using '%' is not good, or it does not matter which version to use?
Quoting from the official documentation,
This method of string formatting is the new standard in Python 3, and should be preferred to the % formatting described in String Formatting Operations in new code.
So, format is the recommended way to do, going forward.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With