Sep 2, 2009

Backslashes and Forward slashes

Windows requires that paths are written with backslashes (\). If your path is currently forward slashed (/), you just need to use:
path_better = path.replace('/','\\')
To convert the forward slashes to backward ones. Note that the reason why I used TWO backslashes is because the single backslash escapes special characters (except in raw strings).
Of course, if what you need is to convert from backward to forward slash, just swap the order in the brackets. That is --> ('\\','/')

Tags: Converting Convert backward forward slash slashes