[Tutor] String formatting

Andy W toodles@yifan.net
Sun, 13 Jan 2002 19:54:22 +0800


Hi folks,

Is there a way in which I can format a string, but escape a particular "%"?
For example, take the following case:

#
val_dict={'score':100}
print "You scored %(score)%."%val_dict
#

What I want as the output is "You scored 100%.", but this will not work due
to "incomplete formatting". Of course I can always use a character that
won't be present (NUL), and replace it with "%", but I'd like to know if
there's a cleaner, more Pythonic solution.

Andy