Python symbolic links on windows do not show up

ぃ、小莉子 提交于 2019-12-12 01:38:41

问题


I have seen answers about how to create symbolic links on Windows using Python (I am on Win 7). However the links does not show up in the system for some reason even though the call claim success. Am I missing something obvious ?

>>> import ctypes
>>> kdll = ctypes.windll.LoadLibrary("kernel32.dll")
>>> kdll.CreateSymbolicLinkA("C:\\testlink", "C:\\existing_dir", 1)
1
>>> ctypes.WinError()
WindowsError(0, 'The operation completed successfully.')
>>> kdll.CreateSymbolicLinkA("C:\\testlink", "C:\\existing_dir", 1)
0
>>> ctypes.WinError()
WindowsError(0, 'Cannot create a file when that file already exists.')
>>> os.path.exists("C:\\testlink")
False
>>> os.path.islink("C:\\testlink")
False

Why does the calls to the windows api think that that the link was created when python can't see it with os.path.exist ? And neither can I see the link in the file explorer or using dir in cmd on the Windows box. So where did the link go ?

来源:https://stackoverflow.com/questions/35914204/python-symbolic-links-on-windows-do-not-show-up

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!