Get the App
SLTechnology News&Howtos  ›  Development  › 

How to check whether a file has symbolic links to Python

Shulou Source: shulou.com Published: 2022-06-02 22:53:55 10月08日 Update

This article mainly explains "how to check whether the file has Python symbolic links". The explanation in this article is simple and clear, easy to learn and understand. Please follow the idea of Xiaobian and study and learn "how to check whether the file has Python symbolic links" together!

For Python 3.4 and later, you can use the Path class.

from pathlib import Path# rpd is a symbolic link>>> Path('rdp').is_symlink()True>>> Path('README').is_symlink()False

Care must be taken when using the is_symlink() method. As long as the named object is a symbolic link, it returns True even if the target of the link does not exist.

ln -s ../ nonexistentfile flnk Thank you for reading, the above is "how to check whether the file has Python symbolic links" content, after the study of this article, I believe everyone on how to check whether the file has Python symbolic links This problem has a deeper understanding, the specific use of the situation also needs to be verified by practice. Here is, Xiaobian will push more articles related to knowledge points for everyone, welcome to pay attention!

Tags: Links symbols files checks learning content objects that is ideas situations articles methods more versions goals knowledge knowledge points articles follow questions Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno vpn NVidia MariaDB Redmi Docker