I am writing a cross-platform file explorer in python. I am trying to convert any backslashes in a path to slashes in order to deal with all paths in the same format.
I tried not only to use string.replace (str, '\\', '/'), but to manually create a method to search by string and replace instances, and both of them work incorrectly because the path name, for example:
\dir\anotherdir\foodir\more
changes to:
/dir/anotherdir\x0oodir/more
I guess this has something to do with how Python represents escape characters or something like that. How to prevent this?
source
share