Wednesday 3 June 2020

How to get the file base name from a path using python?

>>> import os
>>> base=os.path.basename('/root/dir/sub/file.ext')
>>> base
'file.ext'

No comments:

Post a Comment