Format strings that contain '%'

Erik Max Francis max at alcyone.com
Tue Mar 8 17:39:52 CET 2005


rick_muller at yahoo.com wrote:

> I'm trying to do something along the lines of
> 
>>>> print '%temp %d' % 1
> Traceback (most recent call last):
>   File "<stdin>", line 1, in ?
> ValueError: unsupported format character 't' (0x74) at index 1

Use %%:

 >>> '%%temp %d' % 1
'%temp 1'

-- 
Erik Max Francis && max at alcyone.com && http://www.alcyone.com/max/
San Jose, CA, USA && 37 20 N 121 53 W && AIM erikmaxfrancis
   A wise man never loses anything if he have himself.
   -- Montaigne



More information about the Python-list mailing list