trouble using \ to escape %

Rob Williscroft rtw at freenet.co.uk
Fri Apr 15 19:12:10 EDT 2005


Lucas Machado wrote in news:1113606334.524947.54630
@l41g2000cwc.googlegroups.com in comp.lang.python:

> str1 = "[%s%s]\n\tpath = /mnt/samba/%s%s/\%U" % (list[0], list[1],
> list[0], list[1])
> 

In a format string use '%%' for a single % char':

str1 = "[%s%s]\n\tpath = /mnt/samba/%s%s/%%U" % (list[0], list[1],list[0], 
list[1])


Rob.
-- 
http://www.victim-prime.dsl.pipex.com/



More information about the Python-list mailing list