Asked • 05/02/19

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

2 Answers By Expert Tutors

By:

Austin M. answered • 01/11/21

Tutor
5 (1)

Recent Master's Graduate with a Passion for Helping You Learn

Reet C. answered • 05/03/19

Tutor
5 (10)

Computer Engineer With A Passion For Teaching!

Austin M.

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.