理解什么是symbolic link in Python

  • symbolic link

    软连接,本质是Unix概念,不是Python概念。

  • link in Unix

    A link in UNIX is a pointer to a file.

    Like pointers in any programming languages, links in UNIX are pointers pointing to a file or a directory.

    Creating links is a kind of shortcuts to access a file.

    There are two types of links:

    1. Soft link or Symbolic links
    2. Hard Links

    These links behave differently when the source of the link is moved or removed.

    Symbolic links are not updated(they merely contain a string which is the pathname of its target); hard links always refer to the source, even if moved or removed.

  • Python 相关函数

    os.readlink(path) : returns a string representing the path to which the symbolic link points.

    os.symlink(src, dst) : create symbolic link.

  • References

  1. Soft and Hard links in Unix/Linux

猜你喜欢

转载自blog.csdn.net/The_Time_Runner/article/details/109277045