As we know, windows accept both ""
and "/"
as separator.
But in python, ""
is used. For example, call os.path.join("foo","bar")
, 'foo\bar'
will be returned. What's annoying is that there's an escape character, so you cannot just copy the path string and paste to your explorer location bar.
I wonder is there any way to make python use "/"
as default separator, I've tried change the value of os.path.sep and os.sep to "/"
, but os.path.join
still use ""
.
what's the right way?
PS:
I just don't understand why python is using "" as default separator on windows, maybe old version of windows don't support "/"?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…