将Windows格式化的路径转换为Unix样式

将Windows格式化的路径转换为Unix样式

问题描述:

假设您具有这样的路径:

Suppose you have a path like so:

$myPath = 'C:\Python\27'

在PowerShell中,将路径转换为Unix格式是否比仅替换\更可靠?

Is there a more reliable in PowerShell way of converting that path to Unix format than just replacing the \s like this?

PS C:\> $myPath -replace '\\','/'
C:/Python/27

这就是我要这样做的方式,我对任何其他(内置)方式都不熟悉.

That's the way I would do it, I'm not familiar with any other (built-in) way.