String Formatting with Dictionaries : format « Dictionary « Python Tutorial






After the % character, you add a key enclosed in parentheses, which is followed by the other specifier elements: 

phonebook = {'A': '1', 'B': '2', 'C': '3'}
print "C's phone number is %(C)s." % phonebook
8.8.format
8.8.1.String Formatting with Dictionaries