Escaping slashes (double backslash plague)

Aloysio Figueiredo xpythonist at
Mon Jan 19 13:43:01 CET 2004

I need to replace every ocurrence of '/' in s by '\/'
in order to create a file named s. My first attempt

s = '\/'.join(s.split('/'))

but it doesn't work:

>>> s = 'a/b'
>>> s = '\/'.join(s.split('/'))
>>> s
>>> repr(s)

'\/'.join() escapes the backslashes and I don't know

Any help?

Aloysio Figueiredo


Yahoo! GeoCities: a maneira mais fácil de criar seu web site grátis!

More information about the Python-list mailing list