format_map() - Formats specified values in a string

The format_map method takes a dictionary (key-value pairs) that define the placeholder names and their values that replace the placeholders in a string.

Example

Python
fields = {'salePrice':49, 'discount': .5}
txt = "Sale price: ${salePrice:.2f}! That's a {discount:.0%} savings!"
print(txt.format_map(fields))

Output

Sale price: $49.00! That's a 50% savings!