There is some kind of incestuous relationship between the strings module and the format() function that is built into Python 3.5 and later. About 99% of everything you need (and you do need it) is covered in Big Daddy’s Output – format() Toolbox.
That said, the string module contains two other interesting things you may find of use: a set of constants, and a substitute function called a “template string” that may be easier to implement in some cases than the format() substitution process. The down side, of course, is that you will have to import it while the format() function is always available.
CONSTANTS
string.ascii_letters
For example, yeilds: ‘abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ’
string.ascii_lowercase
string.ascii_uppercase
string.digits
string.hexdigits
string.octdigits
string.punctuation
string.printable
string.whitespace
TEMPLATE STRINGS
Somewhat simplified, here is the general process in an example:
from string import Template x,y,z='First','Second', 1134 #one way or another establish variables to sub ts=Template('Give me $x1 and then $x2 and then $x3.') #create your string with sub place holders astr=ts.substitute(x1=x,x2=y,x3=z) # set sub place holders to your established sub values print (astr)…will yield “Give me First and then Second and then 1134.”
The sub place holders can be made equal to any iterable, including a dictionary. Let your imagination run wild.