I am working in python and I need to convert this:
C:\folderA\folderB to C:/folderA/folderB
I have three approaches:
dir = s.replace('\\','/')
dir = os.path.normpath(s)
dir = os.path.normcase(s)
In each scenario the output has been
C:folderAfolderB
I'm not sure what I am doing wrong, any suggestions?
r'C:\folderA\folderB'- Andy♦s.replace('//', '\')shouldn't even run. The'\'is invalid, you need to escape backslashes. The correct way would bes.replace('/', '\\'). Right now when it's running it will just give you\fwhich is a linefeed character. - Chrispresso