[Tutor] String formatting

Stephan Richter srichter@cbu.edu
Sun, 13 Jan 2002 06:02:11 -0600


At 07:54 PM 1/13/2002 +0800, Andy W wrote:
>Hi folks,
>
>Is there a way in which I can format a string, but escape a particular "%"?

Yep. You simply double your %. Try:

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

Regards,
Stephan

--
Stephan Richter
CBU - Physics and Chemistry Student
Web2k - Web Design/Development & Technical Project Management