problems using % in strings with %(var)s replacements

Duncan Booth duncan at NOSPAMrcp.co.uk
Wed May 23 07:15:51 EDT 2001


"Thomas Weholt" <thomas at cintra.no> wrote in 
news:jPLO6.2171$556.193068 at juliett.dax.net:

> I see the % in 50% is the problem but how can I use the %-char in strings
> and still use %(...)s replacements??
> 

%%
Read http://www.python.org/doc/current/lib/typesseq-strings.html

Strangely(?) you can also specify the mapping key, field width and other 
flags for the %% conversion, although only the field width seems to have 
any possible use:
>>> "%*%" % 6
'     %'
>>> "%*%" % 7
'      %'

-- 
Duncan Booth                                             duncan at rcp.co.uk
int month(char *p){return(124864/((p[0]+p[1]-p[2]&0x1f)+1)%12)["\5\x8\3"
"\6\7\xb\1\x9\xa\2\0\4"];} // Who said my code was obscure?



More information about the Python-list mailing list