ReferenceString methods
str.format()
Fills the placeholders in a template string.
Signature
template.format(*args, **kwargs)Parameters
| Name | Means |
|---|---|
*args | values for the numbered or empty placeholders |
**kwargs | values for the named ones |
Returns
A new string.
Example
Python
print("{} is {}".format("Ada", 36))
print("{0} and {0}".format("again"))
print("{name} is {age}".format(name="Ada", age=36))
print("{:,.2f}".format(1234.5678))Output
Ada is 36 again and again Ada is 36 1,234.57