Python path.join behavior is different when run in Mac vs Windows

后端 未结 1 389
生来不讨喜
生来不讨喜 2021-01-25 11:31

I want my Project, built in PYTHON to support Windows Linux MAC in any terminal(MAC, CYGWIN, Windows etc). I can able to achieve but I am facing some issue When I run the follo

相关标签:
1条回答
  • 2021-01-25 12:11

    This is exactly what you should expect. On Windows, os.path gives you Windows-style paths; on Mac OS X, it gives you POSIX-style paths.

    If you're looking to guarantee POSIX paths everything, don't use os.path at all, use posixpath instead.

    On the other hand, if you've got paths that may be in POSIX format even on Windows (since most parts of Windows handle POSIX-style paths, and many tools generate POSIX-style paths) and want to guarantee that you've got a native path, call os.path.normpath.

    0 讨论(0)
提交回复
热议问题