我正在寻找一种在Python中将完整的Windows“ LFN样式”路径名转换为DOS路径名的方法。 请注意,我不正在寻找答案“反斜杠空格”。 这是一个示例:
'C:\Users\Fred\Foo\Long directory name with many spaces\long filename that also has many spaces.txt'
...将成为...
'C:\Users\Fred\Foo\LONGDI~1\LONGFI~1.TXT'
在cygwin(或Git Bash)中,可以使用命令cygpath -da "$path"
完成。我原本希望在模块os.path
或模块pathlib
中找到某些东西……似乎不在这两个地方。