Skip to main content

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) 

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 
more precision regarding version + url
Source Link
smheidrich
  • 4.6k
  • 1
  • 20
  • 37

In Python 3.4+, you can use the pathlibpathlib module (included in Python's standard library):

from pathlib import Path p = Path("/home/user/Downloads/repo/test.txt") print(p.stem) 

In Python 3, you can use the pathlib library:

from pathlib import Path p = Path("/home/user/Downloads/repo/test.txt") print(p.stem) 

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) 
Source Link
smheidrich
  • 4.6k
  • 1
  • 20
  • 37

In Python 3, you can use the pathlib library:

from pathlib import Path p = Path("/home/user/Downloads/repo/test.txt") print(p.stem)