Mega Code Archive
Categories
/
Python Tutorial
/
String
You can supply the value-name pairs in a dictionary
from string import Template s = Template('A $thing must never $action.') d = { 'thing': 'gentleman', 'action': 'show his socks' } s.substitute(d) print s