Python/pathlib/PurePath/parents

من موسوعة حسوب
< Python‏ | pathlib‏ | PurePath
اذهب إلى التنقل اذهب إلى البحث

المتغير PurePath.parents

سلسة غير قابلة للتعديل (immutable) تُعطي وصولًا للآباء المنطقية للمسار

>>> p = PureWindowsPath('c:/foo/bar/setup.py')

>>> p.parents[0]
PureWindowsPath('c:/foo/bar')

>>> p.parents[1]
PureWindowsPath('c:/foo')

>>> p.parents[2]
PureWindowsPath('c:/')