Python/pathlib/Path/resolve
التابع Path.resolve
يجعل المسار مسارًا مطلقًا، حيث يقوم بإزالة جميع الاختصارات (symlinks)، ويقوم بإعادة كائن مسار جديد.
>>> p = Path()
>>> p
PosixPath('.')
>>> p.resolve()
PosixPath('/home/antoine/pathlib')
“..” components are also eliminated (this is the only method to do so):
>>> p = Path('docs/../setup.py')
>>> p.resolve()
PosixPath('/home/antoine/pathlib/setup.py')
If the path doesn’t exist and strict is True, FileNotFoundError is raised. If strict is False, the path is resolved as far as possible and any remainder is appended without checking whether it exists. If an infinite loop is encountered along the resolution path, RuntimeError is raised.
New in version 3.6: The strict argument.