MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / split

Function split

tools/python-3.11.9-amd64/Lib/ntpath.py:208–223  ·  view source on GitHub ↗

Split a pathname. Return tuple (head, tail) where tail is everything after the final slash. Either part may be empty.

(p)

Source from the content-addressed store, hash-verified

206# The resulting head won't end in '/' unless it is the root.
207
208def split(p):
209 """Split a pathname.
210
211 Return tuple (head, tail) where tail is everything after the final slash.
212 Either part may be empty."""
213 p = os.fspath(p)
214 seps = _get_bothseps(p)
215 d, p = splitdrive(p)
216 # set i to index beyond p's last slash
217 i = len(p)
218 while i and p[i-1] not in seps:
219 i -= 1
220 head, tail = p[:i], p[i:] # now tail has no slashes
221 # remove trailing slashes from head, unless it's all slashes
222 head = head.rstrip(seps) or head
223 return d + head, tail
224
225
226# Split a path in root and extension.

Callers 6

readconfigFunction · 0.90
_bypass_ensure_directoryFunction · 0.90
_bypass_ensure_directoryFunction · 0.90
basenameFunction · 0.70
dirnameFunction · 0.70

Calls 3

_get_bothsepsFunction · 0.85
splitdriveFunction · 0.70
rstripMethod · 0.45

Tested by

no test coverage detected