🔵 🔵 🔵


Primary

၊၊||၊|။

os.path.splitext() ⚬|Documentation|1st|20251021000221-00-⌔

os.path — Common pathname manipulations — Python 3 documentation#os.path.splitext

os.path.splitext(path,/)

Split the pathname path into a pair (root, ext) such that root + ext == path, and the extension, ext, is empty or begins with a period and contains at most one period.

If the path contains no extension, ext will be '':

>>> splitext('bar')
('bar', '')

If the path contains an extension, then ext will be set to this extension, including the leading period. Note that previous periods will be ignored:

>>> splitext('foo.bar.exe')
('foo.bar', '.exe')
>>> splitext('/foo/bar.exe')
('/foo/bar', '.exe')

Leading periods of the last component of the path are considered to be part of the root:

>>> splitext('.cshrc')
('.cshrc', '')
>>> splitext('/foo/....jpg')
('/foo/....jpg', '')

Changed in version 3.6: Accepts a path-like object.

Printed 2026-06-28.

(echo:: @ )

Link to original

Secondary

• • •