Symlinks on windows?

后端 未结 10 1581
轻奢々
轻奢々 2020-11-29 01:09

Does anyone know of a way to make/read symbolic links across versions of win32 from Python? Ideally there should be a minimum amount of platform specific code, as I need my

10条回答
  •  甜味超标
    2020-11-29 01:33

    As mentioned in another answer, using subprocess.call is likely the best option for windows. However calling 'mklink' directly may result in:

    [WinError 2] The system cannot find the file specified

    On Windows Server 2016, I was able to get the following to work for files:

    import subprocess
    subprocess.call(['cmd', '/c', 'mklink', '', ''])
    

    Change the switches above as per mklink docs.

提交回复
热议问题