I have a string containing a filepath for Windows:
import os
dir = os.getcwd()
# bogus name
'C:\\my\\folder'
If I copy and paste dir
in Windows Explorer or other programs, I get an error, the file name is not valid.
I tried the solutions in this question but none worked. The closest I got is:
dir.replace('\\', '/')
'C:/my/folder'
Now it works for some windows programs but not others, so I simply want to replace '\\'
by '\'