我知道 ntpath 是用来解析 windows 路径的,但是我注意到它也适用于 linux-like/posix 路径。有人可以证实这一点吗?是否存在 ntpath 无法解析 linux 路径的任何边缘情况?
提前致谢。
请您参考如下方法:
发件人:http://docs.python.org/2/library/os.path.html
However, you can also import and use the individual modules if you want to manipulate a path that is always in one of the different formats. They all have the same interface:
posixpath
for UNIX-style pathsntpath
for Windows paths
我会检测目录分隔符:\
(windows) 或 /
(unix) 在路径字符串中,然后使用相应模块中的函数。