更新时间:2023-11-25 16:16:46
要确定目录条目是否为符号链接,请使用:
To determine if a directory entry is a symlink use this:
如果路径引用了一个符号目录条目,则返回 True关联.如果不支持符号链接,则始终为 False.
Return True if path refers to a directory entry that is a symbolic link. Always False if symbolic links are not supported.
例如,给定:
drwxr-xr-x 2 root root 4096 2011-11-10 08:14 bin/
drwxrwxrwx 1 root root 57 2011-07-10 05:11 initrd.img -> boot/initrd.img-2..
>>> import os.path
>>> os.path.islink('initrd.img')
True
>>> os.path.islink('bin')
False