Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Python by (1.6k points)

How to get the filename without the extension from a path in Python?

1 Answer

0 votes
by (25.1k points)

You can do it like this:

import os

print(os.path.splitext("/path/to/some/file.txt")[0])

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
asked Jul 18, 2019 in Python by Sammy (47.6k points)
0 votes
1 answer
asked Jul 11, 2019 in Java by Ritik (3.5k points)
0 votes
1 answer

Browse Categories

...