str.format_map(mapping)
Similar to str.format(**mapping)
, except that mapping
is used directly and not copied to a dict
. This is useful if for example mapping
is a dict subclass:
>>> class Default(dict): ... def __missing__(self, key): ... return key ... >>> '{name} was born in {country}'.format_map(Default(name='Guido')) 'Guido was born in country'
New in version 3.2.
Please login to continue.