-1

How to get ONLY filename instead of full path?

For example:

path = /folder/file.txt 

and i need to get:

filename = file.txt 

How to do that?

0

1 Answer 1

2

You should use the os module:

import os filename = os.path.basename(path) 

For other path manipulations look here (for python 2.7) or here (for python 3)

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.