开发者

how to find target path of link if the file is a link file

开发者 https://www.devze.com 2023-01-06 10:05 出处:网络
how to find if the file is a link file, and find the path of the target file (开发者_开发技巧actual file pointed by the link file)os.path.islink (is it a link?) and os.path.realpath (get ultimate poin

how to find if the file is a link file, and find the path of the target file (开发者_开发技巧actual file pointed by the link file)


os.path.islink (is it a link?) and os.path.realpath (get ultimate pointed to path, regardless of whether it's a link).

If os.path.islink is True, and you only want to follow the first link, use os.readlink.


Use os.lstat(), then inspect the st_mode field.

0

精彩评论

暂无评论...
验证码 换一张
取 消