路径
POSIX
posix**(Portable Operating System Interface of UNIX)**表示可移植操作系统接口。MacOS,Linux,Windows都遵守了这个标准
POSIX规定使用/分隔路径:
- Linux:
js
/a/b/c- Windows
js
C:/temp/myfile.htmlWindows
Windows 并没有完全遵循 POSIX 标准。Windows 系统的历史原因所致,早期的 Windows 操作系统采用了不同的设计选择。
在 Windows 系统中,路径使用反斜杠(\)作为路径分隔符。
js
C:\temp\myfile.html在程序中使用,我们需要使用转义字符对\进行转义,确保路径的正确:
js
C:\\temp\\myfile.html当然Windows也支持POSIX的路径表示:
js
C:/temp/myfile.html