I\'m currently writing a script which has to check if all specified folders actually exist. I found out I have to use os.path.isdir() with absolute paths.
I have t
When you are using
os.path.normpath(your_path)
you get rit of frontslash/backslash problemens. (But it can change the meaning, so just know what you are doing. But for normal paths there is no problem)
https://docs.python.org/3.6/library/os.path.html#os.path.normpath
Works very well :)
Escape backslash (\
)
os.path.isdir('X:\\pythonscripts\\src')
or use raw string:
os.path.isdir(r'X:\pythonscripts\src')
without escape, you get wrong path:
>>> '\f'
'\x0c'
>>> print '\f'
>>> print '\\f'
\f
>>> print r'\f'
\f
Rather than use \, you might want to use the os.path.sep so that your code works on other platforms, then you don't have to escape these either.