当前位置: 首页 > 图灵资讯 > 行业资讯> 如何检查文件是否有Python的符号链接?

如何检查文件是否有Python的符号链接?

发布时间:2024-06-06 14:31:29

1、对python Path类可用于3.4及更高版本。

frompathlibimportPath
#rpdisasymboliclink
>>>Path('rdp').is_symlink()
True
>>>Path('README').is_symlink()
False

2、使用is_symlink()方法一定要小心。只要命名对象是符号链接,即使链接的目标不存在,也会返回True。

ln-s../nonexistentfileflnk

以上就是检查文件是否有Python符号链接的方法,希望对大家有所帮助。更多Python学习指导:python基础教程

 

相关文章

python3兼容python2吗

python3兼容python2吗

2025-05-09
python3 whl怎么安装

python3 whl怎么安装

2025-05-09
python 字典怎么提取value

python 字典怎么提取value

2025-05-09
python 怎样计算字符串的长度

python 怎样计算字符串的长度

2025-05-09
python 怎么样反向输出字符串

python 怎么样反向输出字符串

2025-05-09
python 怎么判断字符串开头

python 怎么判断字符串开头

2025-05-09