In Python 3.4+, you can use the pathlib
module (included in Python’s standard library):
>>> from pathlib import Path
>>> p = Path("/home/user/Downloads/repo/test.txt")
>>> print(p.stem)
test
>>> print(p.name)
test.txt
In Python 3.4+, you can use the pathlib
module (included in Python’s standard library):
>>> from pathlib import Path
>>> p = Path("/home/user/Downloads/repo/test.txt")
>>> print(p.stem)
test
>>> print(p.name)
test.txt