Asked • 05/02/19

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

2 Answers By Expert Tutors

By:

Inactive Tutor answered • 01/11/21

Tutor
New to Wyzant

Inactive Tutor answered • 05/03/19

Tutor
New to Wyzant

Inactive Tutor

ntpath is for Windows paths. While this happens to work for your example, it is more generic to use "os.path" as per the Python documentation at https://docs.python.org/3/library/os.path.html
Report

01/11/21

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.