Variables escaping quotes
marklists at mceahern.com
Tue Aug 20 01:41:44 CEST 2002
> Is there a way for a variable to escape quotation marks? For example:
> print "The husband only had $x minutes to live before his wife, in a rage
> of fury and wrath, would descend upon him like a thousand, shrieking
> banshees, to rend his life (not to mention his manhood) from his cowering
> where $x represents the number 10, not literally $x.
x = 10
print "The husband had only %d minutes to live..." % x
This is called string formatting in Python.
More information about the Python-list