[Tutor] String Replacement Question

Jeff Younker jeff at drinktomi.com
Wed May 21 18:39:07 CEST 2008


On May 21, 2008, at 6:42 AM, Kinuthia Muchane wrote:

>>>> st = "String"
>>>> print "%s " %st*3
> String String String
>>>>
>
> Does this help?

Another approach is to use dictionaries for string
replacement.

 >>> subst = {'some': 'thing'}
 >>> print "%(some)s%(some)s%(some)s"  % subst
thingthingthing

-jeff


More information about the Tutor mailing list