Escaping slashes (double backslash plague)
antonmuhin at rambler.ru
Mon Jan 19 14:02:02 CET 2004
Aloysio Figueiredo wrote:
> 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('/'))
why not replace: s.replace('\/', '/')?
Try print s, and you'll see what you want.
> '\/'.join() escapes the backslashes and I don't know
> Any help?
> Aloysio Figueiredo
More information about the Python-list