os.path.isdir() returns False even when folder exists

后端 未结 3 975
无人共我
无人共我 2020-12-19 10:06

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

3条回答
  •  清酒与你
    2020-12-19 10:38

    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 :)

提交回复
热议问题