You can use the string format operator %
to format a set of values from a dictionary
(see Section 9, “Type Ddict: Dictionaries”):
f%D
In this form, the general form for a format code is:
%(k)[p][m[.n]]c
where is a
key in dictionary k, and the rest of the format
code is as in the usual string format operator.
For each format code, the value of
D is used.
Example:
D[k]
>>> named = {'last': 'Poe', 'first': 'Aloysius'}
>>> 'Dear %(first)s %(last)s:' % named
'Dear Aloysius Poe:'