Python/pathlib/PurePath/match

من موسوعة حسوب
< Python‏ | pathlib‏ | PurePath
مراجعة 09:34، 3 أغسطس 2018 بواسطة مصطفى-عطا (نقاش | مساهمات) (أنشأ الصفحة ب'== التابع <code>PurePath.match</code> == Match this path against the provided glob-style pattern. Return True if matching is successful, Falseotherwise. If patter...')
(فرق) → مراجعة أقدم | المراجعة الحالية (فرق) | مراجعة أحدث ← (فرق)
اذهب إلى التنقل اذهب إلى البحث

التابع PurePath.match

Match this path against the provided glob-style pattern. Return True if matching is successful, Falseotherwise.

If pattern is relative, the path can be either relative or absolute, and matching is done from the right:

>>> PurePath('a/b.py').match('*.py')
True

>>> PurePath('/a/b/c.py').match('b/*.py')
True

>>> PurePath('/a/b/c.py').match('a/*.py')
False

If pattern is absolute, the path must be absolute, and the whole path must match:

>>> PurePath('/a.py').match('/*.py')
True

>>> PurePath('a/b.py').match('/*.py')
False

As with other methods, case-sensitivity is observed:

>>> PureWindowsPath('b.py').match('*.PY')
True