path.sep


提供特定于平台的路径片段分隔符:

🌐 Provides the platform-specific path segment separator:

  • \ 在 Windows 上
  • / 在 POSIX 系统上

例如,在 POSIX 上:

🌐 For example, on POSIX:

'foo/bar/baz'.split(path.sep);
// Returns: ['foo', 'bar', 'baz'] 

在 Windows 上:

🌐 On Windows:

'foo\\bar\\baz'.split(path.sep);
// Returns: ['foo', 'bar', 'baz'] 

在 Windows 上,正斜杠(/)和反斜杠(\)都可以用作路径段分隔符;然而,path 方法仅添加反斜杠(\)。

🌐 On Windows, both the forward slash (/) and backward slash (\) are accepted as path segment separators; however, the path methods only add backward slashes (\).