Can't delete / unlink a symlink to directory in python & windows

情到浓时终转凉″ 提交于 2019-12-06 04:37:24

oops, i overlooked it:

since it's a link to a directory, windows, unlike linux, consider the symlink as a directory, therefore:

from DOS:

c:\> rmdir symlink

from python:

>>> os.rmdir( 'symlink' )

and NOT "del symlink", nor "os.unlink()", nor "os.remove()".

This is how it looks like in Linux:

$ mkdir a
$ ln -s a b
$ rm b          #ok, since a symlink is treated as a file

$ ln -s a b
$ rmdir b       # error, not a file
rmdir: failed to remove `b': Not a directory

I will make a guess. What you have may not be a symlink like the ones on *INX, but rather a hard link. You should be able to os.remove() to remove the hard link.

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