os.path.join() and os.path.normpath() both add double backwards slash on windows
python
Solution
`'static\\css\\reset.css'` is the representation of the string `r'static\css\reset.css'`.
The double backsalsh indicates escaping of the backslash - in string literals it has a meaning of "do something special with the next character", which you don't want here.
>>> print('static\\css\\reset.css')
static\css\reset.css
Problem
I want to convert a unix file path, which is in forward-slash format, to a windows file path, which is in backward-slash format. I tried both os.path.join() and os.path.normpath() but both of them seems to add double backwards slash to the result. For example, if I use `os.path.normpath('static/css/reset.css')`, the result is `'static\\css\\reset.css'` instead of `static\css\reset.css`. And `'static/css/reset.css'.replace('/','\\')` gives me the same result as `os.path.normpath`. Is there any way to just get a single-backward-slash-delimited string format? By the way, I'm using Python2.7 on 64-bit Windows 7.