Python/pathlib/Path/symlink to

من موسوعة حسوب

التابع Path.symlink_to

Make this path a symbolic link to target. Under Windows, target_is_directory must be true (default False) if the link’s target is a directory. Under POSIX, target_is_directory’s value is ignored.

>>> p = Path('mylink')

>>> p.symlink_to('setup.py')

>>> p.resolve()
PosixPath('/home/antoine/pathlib/setup.py')

>>> p.stat().st_size
956

>>> p.lstat().st_size
8

Note

The order of arguments (link, target) is the reverse of os.symlink()’s.