mixed slashes with os.path.join on windows

You can use .replace() after path.join() to ensure the slashes are correct:

# .replace() all backslashes with forwardslashes
print os.path.join(a, b, c, d, e).replace("\\","https://stackoverflow.com/")

This gives the output:

c:/myFirstDirectory/mySecondDirectory/myThirdDirectory/myExecutable.exe

As @sharpcloud suggested, it would be better to remove the slashes from your input strings, however this is an alternative.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)